Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
func NewHandler(h ContextHandler) http.Handler
NewHandler returns an http.Handler which wraps the given ContextHandler and creates a background context.Context.
func NewHandlerWithContext ¶
func NewHandlerWithContext(ctx context.Context, h ContextHandler) http.Handler
NewHandlerWithContext returns an http.Handler which wraps the given context and ContextHandler.
Types ¶
type AppError ¶
AppError bundles error data and should only be used as a return type for ContextHandlerFuncWithError functions.
type ContextHandler ¶
ContextHandler defines a handler which receives a passed context.Context with the standard ResponseWriter and Request.
type ContextHandlerFunc ¶
ContextHandlerFunc type is an adapter to allow the use of an ordinary function as a ContextHandler. If f is a function with the correct signature, ContextHandlerFunc(f) is a ContextHandler that calls f.
func (ContextHandlerFunc) ServeHTTP ¶
func (f ContextHandlerFunc) ServeHTTP(ctx context.Context, w http.ResponseWriter, req *http.Request)
ServeHTTP calls the function f(ctx, w, req).
type ContextHandlerFuncWithError ¶
type ContextHandlerFuncWithError func(context.Context, http.ResponseWriter, *http.Request) *AppError
ContextHandlerFuncWithError is an adapter func to allow a context handler function which returns an AppError to be used as a ContextHandler. If f is a function with the correct signature, ContextHandlerFuncWithError(f) is a ContextHandler which calls f and writes the AppError if non-nil.
func (ContextHandlerFuncWithError) ServeHTTP ¶
func (fn ContextHandlerFuncWithError) ServeHTTP(ctx context.Context, w http.ResponseWriter, req *http.Request)