Documentation ¶
Overview ¶
Package httputil provides a few convenience functions for frequent operations on Go's http objects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OAuthHandler ¶
func OAuthHandler(writer http.ResponseWriter, req *http.Request)
OAuthHandler is a generic function for inspecting a request and completing the final OAuth2 redirection dance. Intended to be passed to http.HandleFunc.
Types ¶
type Content ¶
type Content struct { Path string Prefix string DisablePreloading bool // contains filtered or unexported fields }
Content is a utility for managing access, caching, and serving of static content from disk. It is intended for use with the http package.
func (*Content) FaviconHandler ¶
func (self *Content) FaviconHandler(writer http.ResponseWriter, req *http.Request)
FaviconHandler is an http.HandleFunc intended to handle favicon serving. It searches for and serves a file called "favicon.ico" in response to all requests. The basic static Handler can also handle favicons, but FaviconHandler is an optimization that skips path parsing and file lookups, since favicons are loaded very frequently.
func (*Content) Handler ¶
func (self *Content) Handler(writer http.ResponseWriter, req *http.Request)
Handler is an http.HandleFunc that searches for and serves a file from disk (or cache, if it was Preload()ed.)
func (*Content) Preload ¶
Preload searches for and loads a file from disk, and then stores the resulting bytes. It is intended to be used to preload and cache common files that change very little, such as index.html, favicon.ico, and so on. Do NOT use this for files that can change during the lifetime of the server.
func (*Content) RootHandler ¶
func (self *Content) RootHandler(writer http.ResponseWriter, req *http.Request)
RootHandler is an http.HandleFunc intended to handle the root path ("/") mapping. It searches for and serves a file called "index.html" if the request is a GET, or returns an error otherwise.