middleware.go 320 B

12345678910111213141516
  1. package myth
  2. import (
  3. "net/http"
  4. )
  5. // Middleware http middleware
  6. type Middleware func(http.HandlerFunc) http.HandlerFunc
  7. // MiddlewareChain applies middlewares to a http.HandlerFunc
  8. func MiddlewareChain(fn http.HandlerFunc, mws ...Middleware) http.HandlerFunc {
  9. for _, m := range mws {
  10. fn = m(fn)
  11. }
  12. return fn
  13. }