Documentation ¶
Index ¶
Constants ¶
const ( GET Method = "GET" DELETE = "DELETE" HEAD = "HEAD" OPTIONS = "OPTIONS" PATCH = "PATHCH" POST = "POST" PUT = "PUT" )
Supported HTTP Methods for use with Server.Handle and Server.HandlerFunc
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextHandler ¶
type ContextHandler interface {
ServeHTTP(c context.Context, w http.ResponseWriter, r *http.Request)
}
ContextHandler is analogous to http.Handler but takes a Context as the first parameter. Shutdown signals, named routing parameters and any global key value settings are passed via context. Handlers can pass the context to other go functions across API bounndries
func ContextWrapper ¶
func ContextWrapper(h http.Handler) ContextHandler
ContextWrapper is a convenience wrapper for http.Handler into ContextHandler. Do not use this if you have long-running routines.
type ContextHandlerFunc ¶
ContextHandlerFunc is analogous to http.HandlerFunc similar to ContextHandler
func (ContextHandlerFunc) ServeHTTP ¶
func (f ContextHandlerFunc) ServeHTTP(c context.Context, w http.ResponseWriter, r *http.Request)
ServeHTTP enables ContextHandlerFunc to satisfy the ContextHandler interface
type ContextRouter ¶
ContextRouter is an http router integrating a context.
func (*ContextRouter) Handle ¶
func (s *ContextRouter) Handle(method Method, path string, handler ContextHandler)
Handle registers a ContextHandler for the required method and route. See https://github.com/julienschmidt/httprouter for details on named parameters.
func (*ContextRouter) HandleFunc ¶
func (s *ContextRouter) HandleFunc(method Method, path string, handler func(context.Context, http.ResponseWriter, *http.Request))
HandleFunc registers a ContextHandlerFunc for the required method and route. See https://github.com/julienschmidt/httprouter for details on named parameters.
func (*ContextRouter) ServeHTTP ¶
func (s *ContextRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes requests to the appropriate handlers
func (*ContextRouter) Stop ¶
func (s *ContextRouter) Stop()
Stop closes the done channel of the root Context of the server to signal to any long running handlers to stop their work.