forgemux

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

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 New

func New() *Mux

New creates a matcher with the default configuration.

func (*Mux) Capabilities

func (m *Mux) Capabilities() shared.Capabilities

Capabilities reports everything, because this matcher is the reason the wide interface exists.

func (*Mux) Close

func (m *Mux) Close() error

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

func (m *Mux) Handle(method, path string, handler http.Handler)

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

func (m *Mux) HandleRoute(spec shared.RouteSpec) error

HandleRoute registers a parsed route.

func (*Mux) Mount

func (m *Mux) Mount(path string, handler http.Handler)

Mount registers a sub-handler for every method, which is one node rather than the seven-verb loop the older adapters need.

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Mux) UseGlobal

func (m *Mux) UseGlobal(middleware func(http.Handler) http.Handler)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL