Skip to content

Path parameter bug when registering different methods on similar route structures #2201

@rtheunissen

Description

@rtheunissen

Issue Description

When registering these routes, we are seeing unexpected behavior:

  • GET "/task/:customer/:type"
  • DELETE "/task/:customer/:uuid"

The parameters of the DELETE endpoint is now customer and type, instead of customer and uuid.

Checklist

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

Expected behaviour

The parameters of the DELETE endpoint is customer and uuid.

Actual behaviour

The parameters of the DELETE endpoint is customer and type.

Steps to reproduce

Working code to debug

package main

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

func main() {
	server := echo.New()
	server.HideBanner = true

	server.GET("/task/:customer/:type", func(c echo.Context) error {
		fmt.Printf("GET: %v", c.ParamNames())
		return nil
	})
	server.DELETE("/task/:customer/:uuid", func(c echo.Context) error {
		fmt.Printf("DELETE: %v", c.ParamNames())
		return nil
	})

	// Start server
	go server.Start("127.0.0.1:8080")

	// Create client and make request
	client := &http.Client{}
	req, _ := http.NewRequest("DELETE", "http://127.0.0.1:8080/task/CUSTOMER/UUID", nil)
	client.Do(req)
}

Output:

⇨ http server started on 127.0.0.1:8080
DELETE: [customer type]%  

Version/commit

v4.7.2

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