A golang utility for getting base url from *http.Request
$ go get github.com/chnlr/baseurl
package main
import (
"net/http"
"io"
"github.com/chnlr/baseurl"
)
func handler(w http.ResponseWriter, r *http.Request) {
// If this handler is listening on `http://localhost:8080/foo/bar`,
// `baseurl.BaseUrl` is returned `http://localhost:8080`
io.WriteString(baseurl.BaseUrl(r))
}
Please See http://godoc.org/github.com/chnlr/baseurl about more information of this library.
Naoki OKAMURA a.k.a nyarla [email protected]
MIT