webhelp.v1: gopkg.in/webhelp.v1/whredir Index | Files

package whredir

import "gopkg.in/webhelp.v1/whredir"

Package whredir provides some helper methods and handlers for redirecting incoming requests to other URLs.

Index

Package Files

redirect.go

func FullURL Uses

func FullURL(r *http.Request) (*url.URL, error)

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 Uses

func Redirect(w http.ResponseWriter, r *http.Request, redirectTo string)

Redirect is just http.Redirect with http.StatusSeeOther which I always forget.

func RedirectHandler Uses

func RedirectHandler(url string) http.Handler

RedirectHandler returns an http.Handler that redirects all requests to url.

func RequireHTTPS Uses

func RequireHTTPS(handler http.Handler) http.Handler

RequireHTTPS returns a handler that will redirect to the same path but using https if https was not already used.

func RequireHost Uses

func RequireHost(host string, handler http.Handler) http.Handler

RequireHost returns a handler that will redirect to the same path but using the given host if the given host was not specifically requested.

func RequireNextSlash Uses

func RequireNextSlash(h http.Handler) http.Handler

func RequireTrailingSlash Uses

func RequireTrailingSlash(h http.Handler) http.Handler

RequireTrailingSlash makes sure all handled paths have a trailing slash. This helps with relative URLs for other resources.

type RedirectHandlerFunc Uses

type RedirectHandlerFunc func(r *http.Request) string

RedirectHandlerFunc is an http.Handler that redirects all requests to the returned URL.

func (RedirectHandlerFunc) Routes Uses

func (f RedirectHandlerFunc) Routes(
    cb func(method, path string, annotations map[string]string))

Routes implements whroute.Lister

func (RedirectHandlerFunc) ServeHTTP Uses

func (f RedirectHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.handler

Package whredir imports 6 packages (graph) and is imported by 5 packages. Updated 2017-06-04. Refresh now. Tools for package owners.