From 3d80b95f55b56988bb4e4328b68510f4a03d5dd9 Mon Sep 17 00:00:00 2001 From: Maximilian Date: Fri, 7 Jul 2023 18:05:17 -0500 Subject: [PATCH] Initial wrapper implementation --- middleware/wrapper.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 middleware/wrapper.go diff --git a/middleware/wrapper.go b/middleware/wrapper.go new file mode 100644 index 0000000..05d67d9 --- /dev/null +++ b/middleware/wrapper.go @@ -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 +}