Documentation
¶
Index ¶
- type BasicAuth
- type Entre
- func (e *Entre) ForHTTPRouter() httprouter.Handle
- func (e *Entre) Push(h Handler)
- func (e *Entre) PushFunc(...)
- func (e *Entre) PushHandler(h http.Handler)
- func (e *Entre) PushHandlerFunc(hf func(http.ResponseWriter, *http.Request))
- func (e *Entre) Serve(addr string)
- func (e *Entre) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (e *Entre) ServeHTTPForHTTPRouter(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- type Handler
- type HandlerFunc
- type Logger
- type LoggerIface
- type NextHandler
- type NextHandlerFunc
- type PanicRecovery
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicAuth ¶
type BasicAuth struct {
// contains filtered or unexported fields
}
BasicAuth provides the basic authentication middleware.
func NewBasicAuth ¶
NewBasicAuth creates a new basic auth instance with the provided username and password.
func (*BasicAuth) ServeHTTP ¶
func (b *BasicAuth) ServeHTTP(w http.ResponseWriter, r *http.Request, ps httprouter.Params, next http.HandlerFunc)
type Entre ¶
type Entre struct {
// contains filtered or unexported fields
}
Entre provides the functionality for the entre middleware handler.
func Basic ¶
func Basic() *Entre
Basic create a new entre middleware stack from the bundled middleware taking no parameters. This produces a stack with a logging middleware and a panic recovery middleware which prints the panic stack trace to the response.
func (*Entre) ForHTTPRouter ¶
func (e *Entre) ForHTTPRouter() httprouter.Handle
ForHTTPRouter provides an Entre object as a httprouter handler for application's using the httprouter for routing.
func (*Entre) PushFunc ¶
func (e *Entre) PushFunc(hf func(http.ResponseWriter, *http.Request, httprouter.Params, http.HandlerFunc))
PushFunc adds a handler function of the entre handler type to the stack of middleware.
func (*Entre) PushHandler ¶
PushHandler adds a http.Handler to the stack of middleware.
func (*Entre) PushHandlerFunc ¶
func (e *Entre) PushHandlerFunc(hf func(http.ResponseWriter, *http.Request))
PushHandlerFunc adds a http.HandlerFunc based handler on to our stack of middleware.
func (*Entre) Serve ¶
Serve deals with setting up with the web server to listen to the provided port.
func (*Entre) ServeHTTP ¶
func (e *Entre) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP deals with invoking the entre middleware chain for the standard http.Handler integration.
func (*Entre) ServeHTTPForHTTPRouter ¶
func (e *Entre) ServeHTTPForHTTPRouter(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
ServeHTTPForHTTPRouter is the endpoint handler for integration with the httprouter router.
type Handler ¶
type Handler interface {
ServeHTTP(w http.ResponseWriter, r *http.Request, params httprouter.Params, next http.HandlerFunc)
}
Handler provides the base definition for an entre handler that provides the core middleware functionality.
func UseHTTPRouterHandler ¶
func UseHTTPRouterHandler(h httprouter.Handle) Handler
UseHTTPRouterHandler wraps a httprouter handler so it can be used as the part of then entre middleware chain.
func UseHandler ¶
UseHandler provides a way to wrap a http.Handler in an entre.Handler to be used as middleware.
func UseNextHandler ¶
func UseNextHandler(h NextHandler) Handler
UseNextHandler allows entre to take handlers with a next argument.
func UseNextHandlerFunc ¶
func UseNextHandlerFunc(h NextHandlerFunc) Handler
UseNextHandlerFunc allows us to use a handler which allows calling of the next handler in the chain without the expectation of router params.
type HandlerFunc ¶
type HandlerFunc func(http.ResponseWriter, *http.Request, httprouter.Params, http.HandlerFunc)
HandlerFunc provides the definition for a handler function.
func (HandlerFunc) ServeHTTP ¶
func (h HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request, ps httprouter.Params, next http.HandlerFunc)
type Logger ¶
type Logger struct {
LoggerIface
}
Logger is the type which provides our core logging middleware.
func (*Logger) ServeHTTP ¶
func (l *Logger) ServeHTTP(w http.ResponseWriter, r *http.Request, ps httprouter.Params, next http.HandlerFunc)
type LoggerIface ¶
type LoggerIface interface { Println(...interface{}) Printf(string, ...interface{}) }
LoggerIface provides a minimal interface with our middleware logger with the funcionality of a simple middleware logger.
type NextHandler ¶
type NextHandler interface {
ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
}
NextHandler provides the definition for a handler that is not coupled with the httprouter package but allows us to make use of middleware primarily written for libraries like negroni.
type NextHandlerFunc ¶
type NextHandlerFunc func(http.ResponseWriter, *http.Request, http.HandlerFunc)
NextHandlerFunc provides the definition for a handler function which does not make use of httprouter.Params, this is for middleware components built for other routers that have include a reference to the next handler in the chain.
func (NextHandlerFunc) ServeHTTP ¶
func (h NextHandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
type PanicRecovery ¶
type PanicRecovery struct { Logger LoggerIface PrintStack bool ErrorHandlerFunc func(interface{}) StackAll bool StackSize int }
PanicRecovery is the middleware that handles recovery from panics.
func NewPanicRecovery ¶
func NewPanicRecovery(printStack bool) *PanicRecovery
NewPanicRecovery deals with create a new instance to be used in a middleware stack.
func (*PanicRecovery) ServeHTTP ¶
func (pr *PanicRecovery) ServeHTTP(w http.ResponseWriter, r *http.Request, ps httprouter.Params, next http.HandlerFunc)
type Response ¶
type Response interface { http.ResponseWriter http.Flusher // Status returns the code of the response or 200 if the status code // has not yet been written to the response. Status() int // Written determines whether or not response has been written to. Written() bool // BodyLength retrieves the size of the response body. BodyLength() int // Before provides a way for functions to be called before a response is written. // This comes in to play for tasks like setting headers. Before(func(Response)) }
Response provides a wrapper around http.ResponseWriter to make it easier for middleware to evaluate and retrieve information from responses.
func NewResponse ¶
func NewResponse(w http.ResponseWriter) Response
NewResponse provides a wrapper response instance for the provided resposne writer.