echo icon indicating copy to clipboard operation
echo copied to clipboard

Different handlers for the same endpoint without problems.

Open lkeix opened this issue 2 years ago • 1 comments

Issue Description

Different handlers can be executed for the same end point without problems.

example:

func main() {
	router := echo.New()

	group := router.Group("/api")
	group.GET("/:user", handler1)

	router.GET("/api/:user", handler2)

	router.Start(":8080")
}

func handler1(c echo.Context) error {
	user := c.Param("user")
	return c.String(http.StatusOK, user)
}

func handler2(c echo.Context) error {
	user := c.Param("user")
	return c.String(http.StatusOK, user)
}

Actually, It is running handler2 handler on /api/:user. But, this case isn't developer-friendly. If echo engine warn or error above case, developer can notice unexpected behavior like this.

same #1726 ?

Checklist

  • [x] Dependencies installed
  • [x] No typos
  • [x] Searched existing issues and docs

Version/commit

echo: v4.7.2

lkeix avatar May 02 '22 13:05 lkeix

I can not comment if it was intended but last N years you have been able to overwrite routes with new handlers. This is what is happening. It is a "feature" of Echo :)

aldas avatar Jul 13 '22 14:07 aldas

@aldas Thanks comment, I got it.

lkeix avatar Oct 19 '22 13:10 lkeix