1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-28 03:29:35 +02:00
echo/middleware/slash.go

17 lines
351 B
Go
Raw Normal View History

package middleware
import "github.com/labstack/echo"
// StripTrailingSlash returns a middleware which removes trailing slash from request
// path.
func StripTrailingSlash() echo.HandlerFunc {
return func(c *echo.Context) error {
p := c.Request().URL.Path
l := len(p)
if p[l-1] == '/' {
c.Request().URL.Path = p[:l-1]
}
return nil
}
}