Documentation
¶
Overview ¶
Package route matches HTTP requests against net/http.ServeMux patterns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Map ¶
type Map[T any] struct { // contains filtered or unexported fields }
Map assigns a value to each pattern. Build it with Add before sharing it; concurrent Match calls are safe once construction is complete.
func (*Map[T]) Add ¶
Add assigns a value to a "<METHOD> [<host>]/<path>" pattern, which must name an HTTP method. A pattern without a host matches every host.
func (*Map[T]) Match ¶
func (m *Map[T]) Match(requestMethod, requestHost, requestPath string) (value T, wildcards map[string]string, matched bool)
Match returns a request's value and wildcards; requestPath must be escaped. Unlike ServeMux, a GET pattern does not match HEAD, whose empty responses need their own pattern.
Click to show internal directories.
Click to hide internal directories.