Groups
Sign in
Groups
golang-nuts
Conversations
About
Send feedback
Help
Getting all URL query keys and values?
2,213 views
Skip to first unread message
Ralf Rottmann
unread,
Mar 31, 2014, 9:08:52 AM
3/31/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
How do I get all query string keys and values via Golang's http package? Assume I've got a URI like:
http://localhost:8080?a=1&b=2
request.URI.Query()
seems to only return the first pair.
--
rottmann.net
|
Google+
|
Twitter
|
Facebook
|
LinkedIn
Kamil Kisiel
unread,
Mar 31, 2014, 9:28:24 AM
3/31/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
Assuming you mean req.URL.Query()... it does the right thing:
http://play.golang.org/p/ivrCg2jxg-
Ralf Rottmann
unread,
Mar 31, 2014, 10:33:11 AM
3/31/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
Thanks! I can't get it working with http.Request in an http HandleFunc.
Here is my code snippet:
func debug(w http.ResponseWriter, r *http.Request) {
u, _ := url.Parse(r.URL.String())
queryParams := u.Query()
...
On Monday, March 31, 2014 3:08:52 PM UTC+2, Ralf Rottmann wrote:
Ralf Rottmann
unread,
Mar 31, 2014, 10:41:36 AM
3/31/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
My bad. curl doesn't seem to handle multiple query string parameters...
On Monday, March 31, 2014 3:08:52 PM UTC+2, Ralf Rottmann wrote:
Reply all
Reply to author
Forward
0 new messages