I'm building an application using the Micro Service Architecture. On the gateway, I do want to route requests to the correct endpoints.
But, the endpoint are now known at runtime and needs to be configured in the DB.
Below if the code to get the router.
func getRouter() *mux.Router {
r := mux.NewRouter()
r.Use(dynamicRouteMiddleware)
return r
}
The middleware itself is this:
func dynamicRouteMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Println("Error")
})
}
However, the "Error" is never printed. It's only printed when I put a handler for '/'
How can I create middleware without handlers?