You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add middleware and a handler to a route as per the readme, call the route and the handler and middleware run twice, the output is a concat of the two handlers' output.
Expected Behavior
Middleware should run once, handler should run once
Steps To Reproduce
Create the simple example in the readme and then call a router, the middleware and handler will run twice.
flipkickmedia
changed the title
[BUG] handler and middleware running twice due to trailing slash
[BUG] handler and middleware running twice due to trailing slash and middleware defined on pointer reciever
Apr 9, 2024
flipkickmedia
changed the title
[BUG] handler and middleware running twice due to trailing slash and middleware defined on pointer reciever
[BUG] handler and middleware running twice with middleware defined on pointer reciever
Apr 9, 2024
Is there an existing issue for this?
Current Behavior
Add middleware and a handler to a route as per the readme, call the route and the handler and middleware run twice, the output is a concat of the two handlers' output.
Expected Behavior
Middleware should run once, handler should run once
Steps To Reproduce
Create the simple example in the readme and then call a router, the middleware and handler will run twice.
Anything else?
This works as expected:
This causes the failure:
This problem is caused by passing a function which has a pointer reciever. The fix is to return an anonymous function:
However, I want to access specific struct data in the handler context. Looking at the source code:
I'm implementing that interface so it should work. Looking at the readme https://github.com/gorilla/mux?tab=readme-ov-file#middleware what Im doing is documented but this causes a double response.
The text was updated successfully, but these errors were encountered: