Initial wrapper implementation
This commit is contained in:
parent
6da7d408f9
commit
3d80b95f55
13
middleware/wrapper.go
Normal file
13
middleware/wrapper.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user