mirror of
https://github.com/labstack/echo.git
synced 2024-12-22 20:06:21 +02:00
b4da73313f
Signed-off-by: Vishal Rana <vr@labstack.com>
17 lines
351 B
Go
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
|
|
}
|
|
}
|