Skip to content

Params are mixed between routes #1139

Description

@toorop

Edit

it's appear that my problem is due to the fact that params in routes must have the same name between methods if they are at the same position.

If it's the case feel free to close this issue.

Working code to debug

package main

import (
	"log"
	"net/http"

	"github.com/labstack/echo"
)

func main() {
	e := echo.New()
	e.GET("/order/:shopid", func(c echo.Context) error {
		return c.NoContent(http.StatusOK)
	})
	e.DELETE("/order/:ref", func(c echo.Context) error {
		log.Printf("params %v", c.ParamNames())
		foo := c.Param("ref")
		return c.String(http.StatusOK, foo)
	})
	e.Logger.Fatal(e.Start("127.0.0.1:8080"))
}

Expected behaviour

curl -X DELETE http://127.0.0.1:8080/order/toto

  • should output "toto"
  • log should be: 2018/05/28 11:24:25 params [ref]

Actual behaviour

  • no output (foo=="")
  • log is 2018/05/28 11:24:25 params [shopid]

=> routing is correct, the good controler was executed in both case, but params binding are from GET /order/:shopid/pending route

Version

V3.3.dev

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions