We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Registering two routes on different methods with the same path but different param-name results in the last registered param-name wins.
Example:
GET /:bar PUT /:foo
No matter if you request GET or PUT /hello param is always set to foo
/hello
foo
Parameter value is set to the registered name
Parameter value is set to the last registered name on a matching path
With bellow server, run
curl -XGET localhost:4090/hello curl -XPUT localhost:4090/hello
Server outputs
$ go run main.go get: ParamNames [foo] get: ParamValues [hello] put: ParamNames [foo] put: ParamValues [hello]
Swap the order of the method registration and params for both will be set to bar
bar
package main import ( "fmt" "log" "net/http" "github.com/labstack/echo" "github.com/labstack/echo/engine/standard" ) func main() { e := echo.New() e.GET("/:bar", func(ctx echo.Context) error { fmt.Printf("get: ParamNames %+v\n", ctx.ParamNames()) fmt.Printf("get: ParamValues %+v\n", ctx.ParamValues()) return ctx.String(http.StatusOK, "") }) e.PUT("/:foo", func(ctx echo.Context) error { fmt.Printf("put: ParamNames %+v\n", ctx.ParamNames()) fmt.Printf("put: ParamValues %+v\n", ctx.ParamValues()) return ctx.String(http.StatusOK, "") }) log.Fatal(e.Run(standard.New(":4090"))) }
2.1, 04e6901
The text was updated successfully, but these errors were encountered:
@victorhaggqvist Can you confirm if this issue is the same as #634 and #479?
Sorry, something went wrong.
Judging from the code examples, yes I believe so. Sorry about the dupe, feel free to close this one.
Tracked in #479
vishr
No branches or pull requests
Description
Registering two routes on different methods with the same path but different param-name results in the last registered param-name wins.
Example:
No matter if you request GET or PUT
/hello
param is always set tofoo
Expected behavior
Parameter value is set to the registered name
Actual behavior
Parameter value is set to the last registered name on a matching path
Steps to reproduce
With bellow server, run
Server outputs
Swap the order of the method registration and params for both will be set to
bar
Working code to debug
Version/commit
2.1, 04e6901
The text was updated successfully, but these errors were encountered: