Skip to content

Wrong parameter behaviour with specific path #1744

Closed
@ghost

Description

Issue Description

Route router.DELETE takes parameters from router.GET instead of his own parameters.

Checklist

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

Expected behaviour

DeleteTranslation handler receives echo.Context with id parameter without lang parameter

Actual behaviour

DeleteTranslation handler receives lang parameter instead of id parameter

Steps to reproduce

  1. Run server
  2. Request DELETE http://localhost:3333/translation/123

Working code to debug

package main

import (
	"github.com/labstack/echo/v4"
	"net/http"
)

var router = echo.New()

type resp struct {
	Name string
	Lang string
	Id string
}

func GetTranslation (c echo.Context) error {
	return c.JSON(http.StatusOK, resp{Name: "Get", Id: c.Param("id"), Lang: c.Param("lang")})
}

func DeleteTranslation (c echo.Context) error {
	return c.JSON(http.StatusOK, resp{Name: "Delete", Id: c.Param("id"), Lang: c.Param("lang")})
}

func main()  {
	router.GET("/translation/:lang", GetTranslation)
	router.DELETE("/translation/:id", DeleteTranslation)

	router.Start(":8000")
}

Version/commit

go 1.15
github.com/labstack/echo/v4 v4.1.17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions