Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NoCache ¶
func NoCache(wri http.ResponseWriter, req *http.Request)
NoCache is a simple piece of middleware that sets a number of HTTP headers to prevent a router from being cached by an upstream proxy and/or client.
As per http://wiki.nginx.org/HttpProxyModule - NoCache sets:
Expires: Thu, 01 Jan 1970 00:00:00 UTC Cache-Control: no-cache, private, max-age=0 X-Accel-Expires: 0 Pragma: no-cache (for HTTP/1.0 proxies/clients)
This function is based on the NoCache middleware from the Goji web framework.
func NoContent ¶
func NoContent(wri http.ResponseWriter)
NoContent replies to the request with an HTTP 204 "no content" status code.
func NoContentHandler ¶
NoContentHandler returns a simple request handler that replies to each request with an HTTP 204 “no content” reply.
func NoopHandler ¶ added in v0.6.3
NoopHandler returns a http.Handler which ignores the request and doesn't write anything.
func WriteJSON ¶
func WriteJSON(wri http.ResponseWriter, v any) error
WriteJSON encodes v to JSON and writes it to http.ResponseWriter wri. It also sets the response header's "Content-Type" to "application/json". Any errors during encoding will be returned. WriteJSON does not do anything and returns nil, when v is nil.
func WriteJSONError ¶
func WriteJSONError(wri http.ResponseWriter, err error) error
WriteJSONError encodes error err to JSON and writes it to w.
Types ¶
This section is empty.