middlewares

package
v0.0.0-...-4f40287 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

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

func GetCORSMiddleWare() *cors.Cors

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

func GetJWTMiddleWare(jwtSecret []byte, userProp string) *jwtmiddleware.JWTMiddleware

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

type Recovery struct {
	Logger     hermes.Logger
	PrintStack bool
	StackAll   bool
	StackSize  int
}

Recovery is a Negroni middleware that recovers from any panics and writes a 500 if there was one.

func NewRecovery

func NewRecovery(logger hermes.Logger) *Recovery

NewRecovery returns a new instance of Recovery

func (*Recovery) ServeHTTP

func (rec *Recovery) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL