Documentation
¶
Overview ¶
Package whredir provides some helper methods and handlers for redirecting incoming requests to other URLs.
Index ¶
- func FullURL(r *http.Request) (*url.URL, error)
- func Redirect(w http.ResponseWriter, r *http.Request, redirectTo string)
- func RedirectHandler(url string) http.Handler
- func RequireHTTPS(handler http.Handler) http.Handler
- func RequireHost(host string, handler http.Handler) http.Handler
- func RequireNextSlash(h http.Handler) http.Handler
- func RequireTrailingSlash(h http.Handler) http.Handler
- type RedirectHandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FullURL ¶
FullURL returns the full url from the incoming request, regardless of what current whmux.Dir is involved or how req.URL.Path has been edited.
func Redirect ¶
func Redirect(w http.ResponseWriter, r *http.Request, redirectTo string)
Redirect is just http.Redirect with http.StatusSeeOther which I always forget.
func RedirectHandler ¶
RedirectHandler returns an http.Handler that redirects all requests to url.
func RequireHTTPS ¶
RequireHTTPS returns a handler that will redirect to the same path but using https if https was not already used.
func RequireHost ¶
RequireHost returns a handler that will redirect to the same path but using the given host if the given host was not specifically requested.
Types ¶
type RedirectHandlerFunc ¶
RedirectHandlerFunc is an http.Handler that redirects all requests to the returned URL.
func (RedirectHandlerFunc) Routes ¶
func (f RedirectHandlerFunc) Routes( cb func(method, path string, annotations map[string]string))
Routes implements whroute.Lister
func (RedirectHandlerFunc) ServeHTTP ¶
func (f RedirectHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.handler