2023-07-07 23:05:17 +00:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
2023-07-21 21:26:43 +00:00
|
|
|
// ProcessGroup is a wrapper function for the http.HandleFunc function
|
2023-07-21 16:59:01 +00:00
|
|
|
// that takes the function you want to execute (f) and the middleware you want
|
|
|
|
// to execute (m) this should be used when processing multiple groups of middleware at a time
|
2023-07-31 23:37:54 +00:00
|
|
|
func ProcessGroup(f func(w http.ResponseWriter, r *http.Request), m []MiddlewareFunc) func(w http.ResponseWriter, r *http.Request) {
|
2023-07-07 23:05:17 +00:00
|
|
|
for _, middleware := range m {
|
2023-07-31 23:37:54 +00:00
|
|
|
_ = middleware(f)
|
2023-07-07 23:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return f
|
|
|
|
}
|