Skip to content

Unable to get param value with the paths specified #2364

Closed
@ghost

Description

Hi All,

With the below configuration, I am not able to get the path param in the GET request.

import "github.com/labstack/echo/v4"

e := echo.New()

e.POST("/attributes/group/:confirm", func(c echo.Context) error { return c.NoContent(http.StatusOK) })
e.PATCH("/attributes/group/:confirm", func(c echo.Context) error { return c.NoContent(http.StatusOK) })
e.POST("/attributes/groups/:activated", func(c echo.Context) error { return c.NoContent(http.StatusOK) })
e.GET("/attributes/group/:id", func(c echo.Context) error {
	param := c.Param("id")
	log.Println("the param is", param)
	return c.NoContent(http.StatusOK)
})
e.POST("/attributes/group/reorder", func(c echo.Context) error { return c.NoContent(http.StatusOK) })
e.DELETE("/attributes/group/:id", func(c echo.Context) error { return c.NoContent(http.StatusOK) })

The log print in the GET function handler prints the param blank.

Just to check if my understanding of the routes is wrong, I tested the same in gin, and it is working properly.

For now changed the path of the GET request slightly to overcome this issue, but could someone please explain why this doesn't work.

Thanks.

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