I am developing a project with Go. I wrote a middleware for this project and it works quite correctly. However, I don’t want the middleware to be affected when a request is sent to the login route because I get a “Missing Authorization header” error. So I added this code in middleware:
if c.Path() == "/login" {
return c.Next()
}
When I add this, I get the error “404 cannot post /login”. What is the reason for this? My other codes are:
container.Invoke(func(loginRoute *userroutes.LoginRoute) {
if loginRoute == nil {
return
}
app.Post("/login", loginRoute.Handler)
})
and
func BuildContainer() *dig.Container {
container := dig.New()
container.Provide(
trait.NewLoginHandler,
)
return container
}
8