fix: move implementation to "internal" package
This commit was merged in pull request #138.
This commit is contained in:
14
internal/handler/middleware/wrapper.go
Normal file
14
internal/handler/middleware/wrapper.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package middleware
|
||||
|
||||
import "net/http"
|
||||
|
||||
// Chain list of handlers together.
|
||||
func Wrapper(next http.Handler, handlers ...func(http.Handler) http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
lastHandler := next
|
||||
for _, handler := range handlers {
|
||||
lastHandler = handler(lastHandler)
|
||||
}
|
||||
lastHandler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user