Procyon|Docs
HTTPRouting

Matching

Understand how mapped routes become endpoint definitions.

Mapped routes are stored as endpoint definitions. The request pipeline later uses an endpoint matcher to select the endpoint for the current request.

endpoint.go
type EndpointDataSource interface {
	// Endpoints returns every endpoint definition available to the router.
	Endpoints() []*Endpoint
}

type EndpointMatcher interface {
	// Match selects the endpoint for the current request context.
	Match(ctx *Context) (*Endpoint, bool)
}

Most applications do not implement these directly. They are framework extension points for custom routing behavior, tests around route selection, or alternate endpoint sources.

Endpoint definition

An endpoint contains the method, route pattern, and request delegate.

endpoint.go
type Endpoint struct {
	// method is the HTTP method this endpoint responds to.
	method Method

	// path is the route pattern associated with this endpoint.
	path string

	// delegate is invoked when the endpoint matches a request.
	delegate RequestDelegate
}

Handlers and middleware do not need to construct endpoints manually. Route mapping creates them for you.