goutils/middleware/chain.go

17 lines
273 B
Go
Raw Permalink Normal View History

package middleware
import (
"net/http"
"slices"
)
type HandlerBuilder func(http.Handler) http.Handler
func ChainMiddlewares(base http.Handler, links ...HandlerBuilder) http.Handler {
slices.Reverse(links)
for _, f := range links {
base = f(base)
}
return base
}