New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse query parameter /hello?name=username #9
Comments
The router matches against the request method and the requested URL path only. You can get the query parameter values e.g. this way: func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
queryValues := r.URL.Query()
fmt.Fprintf(w, "hello, %s!\n", queryValues.Get("name"))
} |
@julienschmidt |
func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
queryValues := r.URL.Query()
fmt.Fprintf(w, "hello, %s!\n", queryValues.Get("name"))
} The URL query is NOT part of the URL path. The router only matches against the request method and the path. |
Thanks for quick response. Gratitude. But after looking through the README and testing, the router should go like this then to parse the URL. It works. |
when i tried to get v := r.URL.Query() it omittted the + sign from email . |
@preetamyadav Just must query-escape values first before using them in an URL query. |
Thanks @julienschmidt |
I am not sure email for help is mentioned or there is a mailing list for this project.
How do parse query parameter? Like I have /hello?name=abhijit the for this pattern I should get "abhijit" when I read from ps.ByName("name"), however unable to read
The text was updated successfully, but these errors were encountered: