Documentation
¶
Overview ¶
Package rewrite holds the pure path logic behind KDexPage rewrite mode (kdex-tech/host-manager#217), shared by the page controller's static placeholder check and the host's request-time dispatch.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("rewrite: path values name no target route")
ErrNotFound reports request values that name no target route: a single-segment {name} value holding a '/' (a decoded %2F, which must not let one wildcard span segments of the target), or an empty value that leaves '//' (a missing segment, not a malformed one). It is a 404, not a 400.
var ErrUnsafe = errors.New("rewrite: substituted path is unsafe")
ErrUnsafe reports a dispatch path that would contain '//' or a '.'/'..' segment after substitution. The CRD's CEL constrains the author's template; this guards the request-supplied values substituted into it.
Functions ¶
func Placeholders ¶
Placeholders returns the bare names of the {name} / {name...} placeholders in a rewrite path template, in order.
func Target ¶
Target builds the path a rewrite dispatches to. An empty tmpl returns exact, the path the target's base route answers at (its basePath since #220), so the dispatch lands on that route rather than on a redirect that would expose the target URL. Otherwise each {name} (or {name...}) is replaced by value(name) and the result is joined to basePath with exactly one '/'. patternPath is the alias page's own pattern: it says which names are multi-segment wildcards.
It returns ErrUnsafe (400) when a value would introduce '//' or a '.'/'..' segment, and ErrNotFound (404) when a single-segment value holds a '/' or when the only '//' comes from an empty value.
func UnknownPlaceholders ¶
UnknownPlaceholders returns the placeholders in tmpl that are not wildcard names in patternPath -- they could never be substituted at request time.
Types ¶
This section is empty.