route

package
v0.13.0 Latest Latest
Warning

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

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

Documentation

Overview

Package route matches HTTP requests against net/http.ServeMux patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 New

func New[T any]() *Map[T]

New returns an empty map.

func (*Map[T]) Add

func (m *Map[T]) Add(pattern string, value T) error

Add assigns a value to a "<METHOD> /<path>" pattern. Patterns must name an HTTP method and must not include a host.

func (*Map[T]) Match

func (m *Map[T]) Match(requestMethod, requestPath string) (value T, matched bool)

Match returns the value assigned to a request method and escaped path. Unlike ServeMux, a GET pattern does not match HEAD, whose empty responses need their own pattern.

Jump to

Keyboard shortcuts

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