Skip to content

Commit

Permalink
NewNormalMiddlewareOnion add arg "xRealIp"
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjm committed May 21, 2017
1 parent fadfae8 commit 0abaa36
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fasthttpmiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ func NewMiddlewareOnion(middlewares ...Middleware) MiddlewareOnion {
}

// NewNormalMiddlewareOnion returns a normal middleware onion. recover -> auth -> log.
// the type of AuthFunc is "func(ctx *fasthttp.RequestCtx) bool"
func NewNormalMiddlewareOnion(authFunc AuthFunc, logger *zap.Logger) MiddlewareOnion {
// the type of AuthFunc is "func(ctx *fasthttp.RequestCtx) bool".
// if your app is behind of Nginx, you may meed to set xRealIp to True so that get an actual remote address.
func NewNormalMiddlewareOnion(authFunc AuthFunc, xRealIp bool, logger *zap.Logger) MiddlewareOnion {
return MiddlewareOnion{[]Middleware{
NewLogMiddleware(logger, true),
NewLogMiddleware(logger, xRealIp),
NewAuthMiddleware(authFunc),
NewRecoverMiddleware(logger),
}}
Expand Down

0 comments on commit 0abaa36

Please sign in to comment.