routing

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RoutePattern

type RoutePattern struct {
	Original   string
	Regex      *regexp.Regexp
	ParamNames []string
	Depth      int
}

RoutePattern represents a compiled route pattern with parameters

func ParseRoutePattern

func ParseRoutePattern(pattern string) (*RoutePattern, error)

ParseRoutePattern converts a route template into a regex pattern and parameter names Supported formats:

  • /users/{id}
  • /files/{name}/raw
  • /posts/{year:\d{4}}/{slug:[^/]+}
  • /api/{version}/users/{id:\d+}/profile
  • /static/{*:.*} (wildcard parameter for "at the end")

Everything outside of {…} is safely regex-escaped Trailing slash is ignored at compile-time; both /path and /path/ are accepted at match-time Wildcard parameters (*) can match any characters including slashes

func (*RoutePattern) Match

func (rp *RoutePattern) Match(path string) (bool, iter.Seq2[string, string])

Jump to

Keyboard shortcuts

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