echo
echo copied to clipboard
Can don't change req.RequestURI in middleware.RemoveTrailingSlash()?
Issue Description
Can don't change req.RequestURI in middleware.RemoveTrailingSlash()?
My app has a variable url prefix, the url prefix can change by config file. So I add e.Pre(middleware.RemoveTrailingSlash())
my code is:
e.Pre(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
req := c.Request()
url := req.URL
url.Path = strings.TrimPrefix(url.Path, "/myprefix")
return next(c)
}
})
e.Pre(middleware.RemoveTrailingSlash())
// xxxx
e.Get("/hello", func(c echo.Context) error {
uri := c.Request().RequestURI
// uri is /hello,want /myprefix/hello
})
but I add middleware.RemoveTrailingSlash(), and cannot get raw RequestURI in my codes.
Can fix it https://github.com/labstack/echo/blob/master/middleware/slash.go#L63 https://github.com/labstack/echo/blob/master/middleware/slash.go#L67
Checklist
- [x] Dependencies installed
- [x] No typos
- [x] Searched existing issues and docs
Hi @runner-mei , this may be controversial advice but you can copy the RemoveTrailingSlash
middleware code and create you own middleware out of it and strip/change everything you need.
@aldas add a option to control change or no change?