Skip to content

static routing and dynamic routing conflicts problems. #1406

@pxlh007

Description

@pxlh007

Issue Description

If static routing and dynamic routing have only the last or several characters different, there will be routing conflicts.

Checklist

e.GET("/ups/person",hello)
e.GET("/users/new", hello)
e.GET("users/:name", hello)

curl localhost:1323/users/new --- ok
curl localhost:1323/users/new2 --- 404

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

Expected behaviour

curl localhost:1323/users/new --- ok
curl localhost:1323/users/new2 --- ok

Actual behaviour

curl localhost:1323/users/new --- ok
curl localhost:1323/users/new2 --- 404

Steps to reproduce

Working code to debug

package main
  
import (
  "net/http"
  "github.com/labstack/echo"
  "github.com/labstack/echo/middleware"
)

func main() {
  // Echo instance
  e := echo.New()

  // Middleware
  e.Use(middleware.Logger())
  e.Use(middleware.Recover())

  // Routes
  e.GET("/", hello)
  e.GET("/ups/person",hello)
  e.GET("/users/new", hello)
  e.GET("/users/:name", hello)

  // Start server
  e.Logger.Fatal(e.Start(":1323"))
}

// Handler
func hello(c echo.Context) error {
  return c.String(http.StatusOK, "Hello, World!")
}

Version/commit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions