authgear / authgear-server

Open source alternative to Auth0 / Firebase Auth
https://www.authgear.com
Apache License 2.0
82 stars 37 forks source link

Switch to a more performant HTTP router #26

Closed louischan-oursky closed 4 years ago

louischan-oursky commented 4 years ago
type Middleware interface {
    Handler(http.Handler) http.Handler
}

type MiddlewareFunc func(http.Handler) http.Handler

func (m MiddlewareFunc) Handler(h http.Handler) http.Handler {
    return m(h)
}

func Chain(ms ...Middleware) Middleware {
    return MiddlewareFunc(func(handler http.Handler) http.Handler {
        for i = len(ms) - 1; i >= 0; i-- {
            handler = ms[i].Handler(handler)
        }
        return handler
    })
}
louischan-oursky commented 4 years ago

Fixed in https://github.com/authgear/authgear-server/pull/34