Skip to content
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

[BUG] First middleware does not get called when there are multiple routes with the same path but different path parameter functions #1552

Closed
pipe01 opened this issue Jul 6, 2020 · 3 comments

Comments

@pipe01
Copy link

pipe01 commented Jul 6, 2020

Describe the bug
When you add multiple middlewares using app.UseGlobal and you have multiple routes that have the same path and the same parameters, but each route's parameter uses a different func for matching, the first middleware won't get called on routes starting from the second one. For example: https://github.com/pipe01/iris-bug/blob/master/main.go

To Reproduce
Steps to reproduce the behavior:

  1. git clone https://github.com/pipe01/iris-bug
  2. go run .
  3. On another terminal: ./call.sh

Expected behavior
The script should output

---
Called first middleware
Called second middleware
first route
---
Called first middleware
Called second middleware
second route
---
Called first middleware
Called second middleware
third route
---

Instead, it outputs:

---
Called first middleware
Called second middleware
first route
---
Called second middleware
second route
---
Called second middleware
third route
---

Desktop (please complete the following information):

  • OS: Ubuntu 19.10
  • Go 1.13.1
@kataras
Copy link
Owner

kataras commented Jul 6, 2020

Thanks a lot @pipe01! That is fixed and a test-case added, however you could just use app.Use there, UseGlobal is required if called right before Listen/Run function.

@pipe01
Copy link
Author

pipe01 commented Jul 6, 2020

Ah I didn't know that, thank you!

@kataras
Copy link
Owner

kataras commented Jul 6, 2020

No, I thank you. That was a pretty good bug report and helped me fix the bug quick!

kataras added a commit that referenced this issue Jul 26, 2020
Former-commit-id: 953df27468e3905e557bb1f6a97ea431cb60f6a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants