1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-22 20:06:21 +02:00
echo/middleware/slash.go
Vishal Rana b4da73313f Removed RedirectToSlash middleware
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-07-28 15:26:17 -07:00

17 lines
351 B
Go

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
}
}