GO - net/http - how to get request string and method
You can use the following fields of the Request struct:
Method string
and
RequestURI string
I suggest you to look at the source code of the struct: Request struct source code
You can access it by clicking on the struct name in the go doc for the net/http package.
In the docs, start from http://golang.org/pkg/net/http and follow the "type Request" link to http://golang.org/pkg/net/http#Request. Everything you need is available as a field or method of Request.
For example, the HTTP method is Request.Method. The path and query parameters are in Request.URL.Path and Request.URL.Query(), respectively.
http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s %q", r.Method, html.EscapeString(r.URL.Path))
})
log.Fatal(http.ListenAndServe(":8080", nil))