Documentation
¶
Overview ¶
Package rewrite routes matching paths as other paths.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(configs ...Config) zinc.Middleware
New changes the routed path of matching requests without a redirect. Query parameters remain untouched. Register it with App.Use or App.UsePrefix, so it runs before routing. Registering it on a group panics, since the route can no longer change there; on a single route it logs a warning the first time it runs.
Types ¶
type Config ¶
type Config struct {
// Rules maps a path to the path to route instead. A path ending in "*"
// matches a prefix, and a "*" in the target is replaced by the rest of
// the path.
//
// When several rules match, an exact rule wins over every "*" rule, and
// among "*" rules the longest prefix wins: with "/*" and "/api/*", a
// request for /api/pets always takes "/api/*". The order is fixed when
// New runs, so every request agrees.
Rules map[string]string
}
Config maps incoming paths to internal paths.
Click to show internal directories.
Click to hide internal directories.