Documentation
¶
Overview ¶
Package radix implements a generic radix tree for HTTP route matching.
- Nodes are static (byte-exact), param ("{name}", matches [^/]+), or catch-all ("{*name}", matches the rest of the path including slashes).
- Only brace params "{name}" / "{*name}" are recognized.
- Static nodes beat params, which beat catch-alls, at the same position — independent of registration order, so a static route is never shadowed.
- A catch-all "{*name}" must be the last segment of a pattern.
- Insert and Search both CleanPath-normalize; both must use the same rule.
Matching is case-sensitive. The tree is generic in the handler value T, so it stores whatever the caller needs (a handler in httpsrv, a string in tests). It never compares two T values, so T may be a func type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Node ¶
type Node[T any] struct { // contains filtered or unexported fields }
Node is a radix tree node. The handler value has type T.
func (*Node[T]) Insert ¶
Insert registers a route. The pattern is CleanPath-normalized then validated; on error the tree is left unchanged.
Click to show internal directories.
Click to hide internal directories.