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

Static route conflict with dynamic on same level - still... #1509

Closed
3 tasks done
pashaosipyants opened this issue Feb 19, 2020 · 3 comments
Closed
3 tasks done

Static route conflict with dynamic on same level - still... #1509

pashaosipyants opened this issue Feb 19, 2020 · 3 comments

Comments

@pashaosipyants
Copy link

Issue Description

If one register 3 routes, where 2 of them are static and start with the same character, and 3rd is dynamic, echo fails to find a handler.

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Related issues #623 , #1406

Steps to reproduce

failing test
code

Working code to debug

	e := echo.New()
	g := e.Group("/g")
	g.GET("/skills", func(ctx echo.Context) error {
		return ctx.String(202, "static skills")
	})
	g.GET("/status", func(ctx echo.Context) error {
		return ctx.String(201, "static status")
	})
	g.GET("/:name", func(ctx echo.Context) error {
		return ctx.String(200, ctx.Param("name"))
	})
	e.Start(":8007")

curl localhost:8007/g/s ---> 404

Version/commit

Checked with versions v4.1.14, v4.1.11

@ds0nt
Copy link

ds0nt commented Feb 19, 2020

I can confirm this weird behavior

2020-02-19-114516_3838x1245_scrot

lammel added a commit to neotel-at/echo that referenced this issue Feb 19, 2020
lammel added a commit to neotel-at/echo that referenced this issue Feb 19, 2020
@lammel
Copy link
Contributor

lammel commented Feb 19, 2020

Thanks for the example code, I put it into a test already and can verify the wrong behaviour.
The root cause is actually the radix routing tree finding a static prefix (it is split on the "s" which /skills and /status have in common) but failing to go back up the routing tree if no match is found.

I'm preparing a PR #1512 for it which will resolve this issue.

@pashaosipyants
Copy link
Author

Approve it works

Thanks @lammel ! 🙂

@vishr vishr closed this as completed in 5ddc3a6 Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants