I need to handle such a request using gorilla/mux:
/objects?id=JDYsh939&id=OYBpo726
As I understood while reading the documentation, I can specify a pattern like this: {name:pattern}
but I don't know if it's would work to specify that the url will contain several times the id parameter.
Any ideas?
答案 0 :(得分:2)
You do not need to specify the parameter for that as the query string parameters go into the corresponding collection of the HttpRequest.
The following code shows how to handle them:
r.HandleFunc("/objects", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello! Parameters: %v", r.URL.Query())
})
See https://golang.org/pkg/net/url/#pkg-examples on how to deal with URL query string parameters.