Documentation ¶
Overview ¶
Recovery middleware for Negroni, heavily inspired by github.com/urfave/negroni/recovery.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCORSMiddleWare ¶
GetCORSMiddleWare returns a pre-configured CORS middleware to handle preflight OPTION requests from CORS aware browsers We may make this more configurable in the future
func GetJWTMiddleWare ¶
GetJWTMiddleWare returns an new jwt middleware ready to be used in negroni the jwtSecret you pass in SHOULD be created with a correct crypto/rand function and be of a good length
Types ¶
type PrincipalMiddleware ¶
type PrincipalMiddleware struct { UserProperty string // contains filtered or unexported fields }
PrincipalMiddleware will extract principals from the current user (ATM from the JWT) NOTE: Since this middleware uses the jwt information produced by the jwt middleware it is important that you systematically place this middleware after the jwt middleware in the stack
func GetPrincipalMiddleware ¶
func GetPrincipalMiddleware(l hermes.Logger, userProp string) *PrincipalMiddleware
GetPrincipalMiddleware is a constructor to a struct that has a ServeHTTP method This only extracts use principals and injects them into the context so authorizations can be computed down the road.
func (*PrincipalMiddleware) ServeHTTP ¶
func (l *PrincipalMiddleware) ServeHTTP( w http.ResponseWriter, req *http.Request, next http.HandlerFunc, )
ServeHTTP implements the middleware interface
type Recovery ¶
Recovery is a Negroni middleware that recovers from any panics and writes a 500 if there was one.
func NewRecovery ¶
NewRecovery returns a new instance of Recovery
func (*Recovery) ServeHTTP ¶
func (rec *Recovery) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)