Skip to content

Different handlers for the same endpoint without problems. #2169

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

Closed
3 tasks done
n9te9 opened this issue May 2, 2022 · 2 comments
Closed
3 tasks done

Different handlers for the same endpoint without problems. #2169

n9te9 opened this issue May 2, 2022 · 2 comments

Comments

@n9te9
Copy link
Contributor

n9te9 commented May 2, 2022

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

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

Version/commit

echo: v4.7.2

@aldas
Copy link
Contributor

aldas commented Jul 13, 2022

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 :)

@n9te9
Copy link
Contributor Author

n9te9 commented Oct 19, 2022

@aldas
Thanks comment, I got it.

@n9te9 n9te9 closed this as completed Oct 19, 2022
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

2 participants