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

Created on 6 Jul 2020  ·  3Comments  ·  Source: kataras/iris

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

resolved bug

All 3 comments

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.

Ah I didn't know that, thank you!

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

Was this page helpful?
0 / 5 - 0 ratings