Documentation
¶
Overview ¶
Package forgemux is forge's in-house route matcher.
It is a segment-level trie rather than a compressed radix tree. Prefix compression saves memory at route counts forge will not reach, and every bug it introduces is one that has to be found here rather than upstream. Segment nodes map one to one onto pathspec.Segment, so insertion is close to transcription.
This package may import internal/pathspec and internal/shared, and nothing else in this repository. internal/router imports it, so any dependency back the other way is a cycle.
Index ¶
- type Mux
- func (m *Mux) Capabilities() shared.Capabilities
- func (m *Mux) Close() error
- func (m *Mux) Configure(cfg shared.MatcherConfig) error
- func (m *Mux) Handle(method, path string, handler http.Handler)
- func (m *Mux) HandleRoute(spec shared.RouteSpec) error
- func (m *Mux) Mount(path string, handler http.Handler)
- func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (m *Mux) UseGlobal(middleware func(http.Handler) http.Handler)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is forge's in-house matcher, implementing shared.ExtendedAdapter.
func (*Mux) Capabilities ¶
func (m *Mux) Capabilities() shared.Capabilities
Capabilities reports everything, because this matcher is the reason the wide interface exists.
func (*Mux) Configure ¶
func (m *Mux) Configure(cfg shared.MatcherConfig) error
Configure applies router-level settings. It is construction-only: changing the miss handlers after routes exist would reinterpret them silently.
func (*Mux) Handle ¶
Handle satisfies the RouterAdapter floor for a caller driving the adapter directly. It parses and delegates; a malformed path is dropped rather than panicking, because this method cannot report an error.
func (*Mux) HandleRoute ¶
HandleRoute registers a parsed route.