For this request GET http://localhost:8080/path?my_key%5B%5D=3&my_key%5B%5D=4&my_key%5B%5D=5
I can't get the data from my_key
. I tried req.URL.Query()["my_key"]
. I can get it if I change the request encoding to from my_key%5B%5D=4&my_key%5B%5D=5
to my_key=4&my_key=5
How can I get request URL's in form of my_key[]=value
Use the net/url package
package main
import (
"fmt"
"net/url"
)
func main() {
utmp := "GET http://localhost:8080/path?my_key%5B%5D=3&my_key%5B%5D=4&my_key%5B%5D=5"
u, err := url.Parse(utmp)
if err != nil {
panic(err)
}
fmt.Println(u.Query()["my_key[]"])
}
http://play.golang.org/p/8aQ00qaa9j
Your key is "my_key[]"
not "my_key"