echo icon indicating copy to clipboard operation
echo copied to clipboard

Allow escaped `:` char in route path after route parameter

Open Kurichi opened this issue 10 months ago • 0 comments

Regarding the google API design custom methods, the issue has been resolved in PR #1988.

However, this solution is not complete as it does not allow a custom method to be appended after a path parameter.

For example in https://service.name/v1/some/resource/{name}:customVerb, the {name} is route parameter, the :customVerb is not route parameter and only is a simple string.

// curl -v -X POST "http://localhost:8088/v1/some/resource/name:undelete"
func main() {
	e := echo.New()

	// route path as Cloud API "custom method"
	// https://cloud.google.com/apis/design/custom_methods
	e.POST("/v1/some/resource/:name\\:undelete", func(c echo.Context) error {
		name := c.Param("name")
		resp := fmt.Sprintf("%s undeleted", name)
		return c.String(200, resp)
	})
	log.Fatal(e.Start(":8088"))
}

Kurichi avatar Mar 16 '25 17:03 Kurichi