Created
April 25, 2020 14:39
-
-
Save Daniel1984/8d55ec19f569e36c702dee90094d1f4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pkg/middleware/middleware.go | |
package middleware | |
import ( | |
"github.com/julienschmidt/httprouter" | |
) | |
type Middleware func(httprouter.Handle) httprouter.Handle | |
func Chain(f httprouter.Handle, m ...Middleware) httprouter.Handle { | |
if len(m) == 0 { | |
return f | |
} | |
return m[0](Chain(f, m[1:]...)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment