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

Documentation said we cannot have Colliding Routes, but actually we can #325

Closed
pascalmail opened this issue Jul 2, 2021 · 3 comments
Closed
Labels

Comments

@pascalmail
Copy link

Describe what are you trying to do
I was reading the KrakenD documentation about creating endpoint at https://www.krakend.io/docs/endpoints/creating-endpoints/.

I saw that there are documentation about KrakenD not supporting Colliding Routes (cannot have /user/:id and /user/new at the same time).

I tried to reproduce it in my machine, but unexpectedly, I can have /user/:id and /user/new at the same time.

Digging deeper, my colleague found out that gin have fixed the inability of httprouter to have mixed param and non-param at gin-gonic/gin#2663

Can the documentation be updated to reflect this? Thank you.

Your configuration file
The content of your krakend.json. When using the flexible configuration option, the computed file can be generated using FC_OUT=out.json

  "version": 2,
  "extra_config": {
    "github_com/devopsfaith/krakend-gologging": {
      "level": "ERROR",
      "prefix": "[KRAKEND]",
      "syslog": false,
      "stdout": true,
      "format": "logstash"
    },
    "github_com/devopsfaith/krakend-logstash": {
      "enabled": true
    }
  },
  "timeout": "3000ms",
  "cache_ttl": "300s",
  "name": "Gateway",
  "encoding": "no-op",
  "endpoints": [
    {
      "endpoint": "/user/{id}",
      "method": "GET",
      "backend": [
        {
          "url_pattern": "/user_id/{id}",
          "method": "GET",
          "host": [ "http://127.0.0.1:4567" ]
        }
      ]
    },
    {
      "endpoint": "/user/new",
      "method": "GET",
      "backend": [
        {
          "url_pattern": "/user/new",
          "method": "GET",
          "host": [ "http://127.0.0.1:4567" ]
        }
      ]
    }
  ]
}

Commands used
How did you start the software?

 krakend -d -c krakend.json run

Logs
If applicable, any logs you saw in the console and debugging information

I run curl to test the endpoint:

▶ curl -XGET localhost:8080/user/new
{"s":"ok"}%

▶ curl -XGET localhost:8080/user/1
{"s":"ok"}%

KrakenD log

[GIN-debug] GET    /__debug/*param           --> github.com/luraproject/lura/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] POST   /__debug/*param           --> github.com/luraproject/lura/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] PUT    /__debug/*param           --> github.com/luraproject/lura/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] PATCH  /__debug/*param           --> github.com/luraproject/lura/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] HEAD   /__debug/*param           --> github.com/luraproject/lura/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] OPTIONS /__debug/*param           --> github.com/luraproject/lura/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] DELETE /__debug/*param           --> github.com/luraproject/lura/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] CONNECT /__debug/*param           --> github.com/luraproject/lura/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] TRACE  /__debug/*param           --> github.com/luraproject/lura/router/gin.DebugHandler.func1 (3 handlers)
[GIN-debug] GET    /__health                 --> github.com/luraproject/lura/router/gin.ginRouter.Run.func1 (3 handlers)
[GIN-debug] GET    /user/:id                 --> github.com/luraproject/lura/router/gin.CustomErrorEndpointHandler.func1 (3 handlers)
[GIN-debug] GET    /user/new                 --> github.com/luraproject/lura/router/gin.CustomErrorEndpointHandler.func1 (3 handlers)
[GIN] 2021/07/02 - 09:08:31 | 200 |    2.490207ms |       127.0.0.1 | GET      "/user/1"
[GIN] 2021/07/02 - 09:08:38 | 200 |    3.687332ms |       127.0.0.1 | GET      "/user/new"

Server log:

127.0.0.1 - - [02/Jul/2021:09:19:14 WIB] "GET /user/new HTTP/1.1" 200 10
- -> /user/new

127.0.0.1 - - [02/Jul/2021:09:19:16 WIB] "GET /user_id/1 HTTP/1.1" 200 10
- -> /user_id/1

@yifanes
Copy link

yifanes commented Jul 5, 2021

Wow, thank you so much for your feedback. Our team has given feedback to httprouter because of this problem before. Theoretically, there should be no conflict because of the existence of priority

@alombarte
Copy link
Member

alombarte commented Jan 10, 2022

Hi @ pascalmail you are right. In the last version we upgraded the gin router to include this change, but on 1.4.1 this is not yet stable and the documentation shouldn't encourage you to do so. There is a problem related with RedirectFixedPath that makes shared prefixes panic. The documentation has been changed in the 2.0 branch with the new fix and will be published when it's safe in the the new 2.0 release
Thanks

@github-actions
Copy link

This issue was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants