I am writing a middleware function in golang net/http using chi but the controller function isn't being executed (couldn't print 1 in the function).
Calling the middleware:
r.With(myMiddleware.Authware).Post("/tryon", mainController.Tryon)
package - myMiddleware
func Authware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Middleware code
})
}
package - mainController
func Tryon(w http.ResponseWriter, r *http.Request) {
// Dosent print anything
log.Println(1)
}
I read the documentation but it didn't help much
Could you please help out debug and let me know why is this happening? Also, if I want to return some data from the middleware to the controller, how do I do it?