Is this behavior a bug?
package main
import (
"net/http"
"github.com/labstack/echo"
"github.com/labstack/echo/engine/standard"
)
func main() {
e := echo.New()
e.GET("/:piyo", func(c echo.Context) error {
return c.String(http.StatusOK, "fail: "+c.Param("piyo"))
})
e.POST("/:hoge", func(c echo.Context) error {
return c.String(http.StatusOK, "success: "+c.Param("hoge"))
})
e.Run(standard.New(":1323"))
}
c.Param("piyo") is empty. 馃槩
It is like that. In this case :piyo is overridden by :hoge; you should use the same name and if that doesn't work get it by index Context.P(0).
Thanks. But, this behavior is unintelligible.
I want to use different params for code readability.
I understand. I will keep this issue open and give it a thought later.
Maybe, IMO https://github.com/trekjs/router/blob/master/index.js
node.maps = {
'GET': {
pnames,
handler
}
}
+1, having a same problem :(
Same issue here. It would be great for the scenario below:
e.Get("/users/:id", handlers.GetUserByID)
e.Get("/users/:name", handlers.GetUserByName)
e.Put("/users/:id", handlers.UpdateUserByID)
In this case, c.Param("name") doesn't work for the 2nd route above. I will use Context.P(0) for now, though.
Most helpful comment
Thanks. But, this behavior is unintelligible.
I want to use different params for code readability.