func RequireTrailingSlash(h http.Handler) http.Handler {
	return whroute.HandlerFunc(h,
		func(w http.ResponseWriter, r *http.Request) {
			if r.URL.Path != "/" && strings.HasSuffix(r.URL.Path, "/") {
				h.ServeHTTP(w, r)
				return
			}
			addTrailingSlash(w, r, h)
		})
}
RequireTrailingSlash makes sure all handled paths have a trailing slash.
This helps with relative URLs for other resources.
package whredir  
import (
	"net/http"
	"net/url"
	"strings"
	"gopkg.in/webhelp.v1/wherr"
	"gopkg.in/webhelp.v1/whmux"
	"gopkg.in/webhelp.v1/whroute"
)
func Redirect(w http.ResponseWriter, r *http.Request, redirectTo string) {
	http.Redirect(w, r, redirectTo, http.StatusSeeOther)
}
type redirectHandler string
func RedirectHandler(url string) http.Handler {
	return redirectHandler(url)
}
func (t redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	Redirect(w, r, string(t))
}
func (t redirectHandler) Routes(
	cb func(method, path string, annotations map[string]string)) {
	cb(whroute.AllMethods, whroute.AllPaths,
		map[string]string{"Redirect": string(t)})
}
var _ http.Handler = redirectHandler("")
var _ whroute.Lister = redirectHandler("")
type RedirectHandlerFunc func(r *http.Request) string
func (f RedirectHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	Redirect(w, r, f(r))
}
func (f RedirectHandlerFunc) Routes(
	cb func(method, path string, annotations map[string]string)) {
	cb(whroute.AllMethods, whroute.AllPaths,
		map[string]string{"Redirect": "f(req)"})
}
var _ http.Handler = RedirectHandlerFunc(nil)
var _ whroute.Lister = RedirectHandlerFunc(nil)
func FullURL(r *http.Request) (*url.URL, error) {
	u, err := url.ParseRequestURI(r.RequestURI)
	if err != nil {
		return nil, err
	}
	u.Scheme = r.URL.Scheme
	u.Host = r.URL.Host
	u.User = r.URL.User
	return u, nil
}
func RequireHTTPS(handler http.Handler) http.Handler {
	return whroute.HandlerFunc(handler,
		func(w http.ResponseWriter, r *http.Request) {
			if r.URL.Scheme == "https" {
				handler.ServeHTTP(w, r)
				return
			}
			u, err := FullURL(r)
			if err != nil {
				wherr.Handle(w, r, err)
				return
			}
			u.Scheme = "https"
			Redirect(w, r, u.String())
		})
}
func RequireHost(host string, handler http.Handler) http.Handler {
	if host == "*" {
		return handler
	}
	return whmux.Host{
		host: handler,
		"*": http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			u, err := FullURL(r)
			if err != nil {
				wherr.Handle(w, r, err)
				return
			}
			u.Host = host
			Redirect(w, r, u.String())
		})}
}
func addTrailingSlash(w http.ResponseWriter, r *http.Request, h http.Handler) {
	u, err := FullURL(r)
	if err != nil {
		wherr.Handle(w, r, err)
		return
	}
	if strings.HasSuffix(u.Path, "/") {
		h.ServeHTTP(w, r)
		return
	}
	u.Path += "/"
	Redirect(w, r, u.String())
}