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 #623

Closed
sokolovstas opened this issue Aug 15, 2016 · 7 comments
Closed

Static route conflict with dynamic on same level #623

sokolovstas opened this issue Aug 15, 2016 · 7 comments
Assignees
Labels

Comments

@sokolovstas
Copy link

Hi,

I have two routes in group:

g.GET("/dictionary/skills", api.GetSkills)
g.GET("/dictionary/:name", api.GetDictionary)

When I call /dictionary/skills or /dictionary/type it work as expected, but when I call /dictionary/status router returns 404. I believe this is because matching work only on first letter for speed sake. When I remove /dictionary/skills route /dictionary/status work normal.

I think this is wrong behaviour, because I want to have common handler on all /dictionary/:name but for exception add only /dictionary/skills.

@ipfans
Copy link
Contributor

ipfans commented Aug 16, 2016

I think it should be some behaviour due to your code. As example:

    e := echo.New()
    g := e.Group("/g")
    g.GET("/dictionary/skills", func(ctx echo.Context) error {
        return ctx.String(200, "skills")
    })
    g.GET("/dictionary/:name", func(ctx echo.Context) error {
        return ctx.String(200, ctx.Param("name"))
    })

Routers are working fine.

@sokolovstas
Copy link
Author

Yes your example work as expected! Thank you for it. I will try figure out source of problem and write later.

@sokolovstas
Copy link
Author

sokolovstas commented Sep 23, 2016

Please check this exmaple. For me http://localhost:8001/g/dictionary/status return Not Found but http://localhost:8001/g/dictionary/type return type. If remove g.GET("/server", than status request work as expected.

e := echo.New()
g := e.Group("/g")
g.GET("/dictionary/skills", func(ctx echo.Context) error {
    return ctx.String(200, "skills")
})
g.GET("/dictionary/:name", func(ctx echo.Context) error {
    return ctx.String(200, ctx.Param("name"))
})
g.GET("/server", func(ctx echo.Context) error {
    return ctx.String(200, "server")
})

@sokolovstas
Copy link
Author

Hi @vishr, do you have any thought about this error?

@vishr
Copy link
Member

vishr commented Oct 14, 2016

@sokolovstas I believe this issue is related to #675. I will work on it asap.

@vishr vishr self-assigned this Oct 14, 2016
@vishr vishr added the bug label Oct 14, 2016
@vishr vishr closed this as completed in acefe3e Oct 14, 2016
@vishr
Copy link
Member

vishr commented Oct 14, 2016

@sokolovstas please verify

vishr added a commit that referenced this issue Oct 14, 2016
Signed-off-by: Vishal Rana <vr@labstack.com>
vishr added a commit that referenced this issue Oct 14, 2016
Signed-off-by: Vishal Rana <vr@labstack.com>
@sokolovstas
Copy link
Author

Yes it working fine now! Many thanks for your efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants