Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultNotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var contentType string var body []byte switch httputil.NegotiateContentType(r, []string{ "text/html", "text/plain", "application/json", }, "text/html") { case "text/plain": contentType = "text/plain" body = []byte(`Error 404 - The requested route does not exist. Make sure you are using the right path, domain, and port.`) case "application/json": contentType = "application/json" body = page404JSON case "text/html": fallthrough default: contentType = "text/html" body = page404HTML } w.Header().Set("Content-Type", contentType+"; charset=utf-8") w.WriteHeader(http.StatusNotFound) _, _ = w.Write(body) return })
DefaultNotFoundHandler is a default handler for handling 404 errors.
Functions ¶
func PermanentRedirect ¶ added in v0.0.11
func PermanentRedirect(to string) func(rw http.ResponseWriter, r *http.Request, _ httprouter.Params)
PermanentRedirect permanently redirects (302) a path to another one.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.