-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global middlewares are not always executed #2413
Comments
you enable redirecting, so server will response a new url to client, then the client will visit new url. use |
@shlinym , please read again the issue, because the 301 is ok and the client (cURL) not following it is also ok. I did not put the request/response on the Expectations nor the Actual Result section, because they don't matter for my point. The only thing that matters is that the global middleware is not executed in this scenario in opposition of what the documentation says
if the middleware was a CORS adapter, the browser won't follow such redirect due the lack of required CORS headers (since the middleware won't ever be executed for that request). |
sorry for my misunderstanding, |
Description
The documentation for the
Use
function saysBut this is not accurate since the router can return a redirect without executing any of the declared middlewares. https://github.com/gin-gonic/gin/blob/master/gin.go#L406-L434
For some middlewares it is ok. But for features such as CORS, instrumentation, rate-limiting and others, it is not.
How to reproduce
and then
Expectations
I would expect 3 custom log lines in the stdout
Actual result
The logs are not present because the middleware is not executed
Environment
The text was updated successfully, but these errors were encountered: