14 lines
287 B
Go
14 lines
287 B
Go
package middlewares
|
|
|
|
import "net/http"
|
|
|
|
type ContextKey string
|
|
type MiddlewareFunc func(http.Handler) http.Handler
|
|
|
|
func ChainMiddlewares(start http.Handler, middlewares ...MiddlewareFunc) http.Handler {
|
|
next := start
|
|
for _, h := range middlewares {
|
|
next = h(next)
|
|
}
|
|
return next
|
|
}
|