Skip to main content

Trailing Slash

TrailingSlash removes trailing slashes before route dispatch.

app.Use(middleware.TrailingSlash())

This lets /users/ match a route registered as /users.

Use AddTrailingSlash for the opposite behavior.

app.Use(middleware.AddTrailingSlash())

Use redirects when the client should see the canonical URL.

app.Use(middleware.TrailingSlashWithConfig(middleware.TrailingSlashConfig{
Redirect: true,
StatusCode: zinc.StatusPermanentRedirect,
}))