Closed Karitham closed 1 year ago
Before:
mw := map[string]func(http.Handler) http.Handler{
"pathMiddleware": func(h http.Handler) http.Handler {
called = true
return h
},
"operationMiddleware": func(h http.Handler) http.Handler { return h },
}
After:
mw := Middlewares{
Path: func(h http.Handler) http.Handler {
called = true
return h
},
Operation: func(h http.Handler) http.Handler { return h },
}
This PR cleans up the ugly middleware map in favor of a clean, generated struct.
The goal is to profit from the excellent autocompletion provided by IDEs to work faster.
As an added bonus, if you had previously used a middleware and forgot it in the spec, the code wont compile, as opposed to silently running, ensuring not ever forgetting a middleware both in the code and in the spec (If you've never typed it, I can't do anything for you)