Go: Get Query Parameters From the URL / URI


The low-API approach isn't to use the web package but the http package to accomplish this.


// ..
import http
// ..
func cmd(w http.ResponseWriter, r *http.Request) {
    c := appengine.NewContext(r)
    c.Logf("r.URL.Path: " + r.URL.Path)
    c.Logf("r.FormValue(\"foo\"): " + r.FormValue("foo"))
    c.Logf(r.FormValue("bar"))
    c.Logf("r.URL.RawQuery: " + r.URL.RawQuery)
}
// ..

...and the output is:
 
2011/05/14 12:26:11 r.URL.Path: /cmd
2011/05/14 12:26:11 r.FormValue("foo"): My_Param_Value
2011/05/14 12:26:11 query_parameters
2011/05/14 12:26:11 r.URL.RawQuery: foo=My_Param_Value&bar=query_parameters

Comments

Popular posts from this blog

Eclipse sucks, so use NetBeans!

Tuning ext4 for performance with emphasis on SSD usage

Tuning ext3 for performance without losing its data integrity potential