GoWeb/middleware/wrapper.go
2023-07-07 18:05:17 -05:00

14 lines
402 B
Go

package middleware
import "net/http"
// ProcessMiddleware is a wrapper function for the http.HandleFunc function
// that takes the function you want to execute (f) and the middleware you want to execute (m)
func ProcessMiddleware(f func(w http.ResponseWriter, r *http.Request), m []func()) func(w http.ResponseWriter, r *http.Request) {
for _, middleware := range m {
middleware()
}
return f
}