Skip to content

Static route conflict with dynamic on same level #623

Closed

Description

@sokolovstas

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.

Activity

  1. ipfans commented on Aug 16, 2016

    @ipfans
    Contributor

    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.

  2. sokolovstas commented on Aug 16, 2016

    @sokolovstas
    Author

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

  3. sokolovstas commented on Sep 23, 2016

    @sokolovstas
    Author

    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")
    })
    
  4. sokolovstas commented on Oct 14, 2016

    @sokolovstas
    Author

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

  5. vishr commented on Oct 14, 2016

    @vishr
    Member

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

  6. self-assigned this
    on Oct 14, 2016
  7. vishr commented on Oct 14, 2016

    @vishr
    Member

    @sokolovstas please verify

  8. added 2 commits that reference this issue on Oct 14, 2016
    1dcb7ba
    2bdbf69
  9. sokolovstas commented on Oct 19, 2016

    @sokolovstas
    Author

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

  10. added a commit that references this issue on Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions