Skip to main content

Rewrite

Rewrite changes the request path before Zinc dispatches the route.

app.Use(middleware.Rewrite("/old", "/new"))

The client does not receive a redirect. Handlers see the rewritten path.

Wildcard rewrites use * in the source and destination.

app.Use(middleware.RewriteWithRules(map[string]string{
"/v1/*": "/api/v1/*",
}))

Use RewriteWithConfig when a Skipper is needed.