I'm looking to access the full URL of an HTTP request. When the following code is run with:
$ curl "
http://localhost:8080/foo"
It prints out:
/foo
/foo
/* **** Code ****
package main
import (
"fmt"
"net/http"
)
func someHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.String())
fmt.Println(r.RequestURI)
}
func main() {
http.HandleFunc("/", someHandler)
http.ListenAndServe(":8080", nil)
}
Is the full URL tucked away any where? If not, I'm curious what the reasoning might be? Or is there a simple call to reassemble the full URL from the request? url.URL.String() doesn't seem to do that, as I would have expected.
I've googled the heck out of this, but came up dry.
Thanks in advance,
Pete