pathtemplate

package
v2.0.1 Latest Latest
Warning

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

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

Documentation

Overview

Package pathtemplate provides utilities for parsing and matching URI path templates containing capture groups.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchResult

type MatchResult struct {
	// Captured is the part of the path captured by the {} group.
	Captured string
	// Rest is the remaining part of the path after the template segments.
	Rest string
}

MatchResult contains the result of a successful path match.

type Template

type Template struct {
	// contains filtered or unexported fields
}

Template represents a compiled path template.

func New

func New(raw string) (*Template, error)

New compiles a raw path template string into a Template. A template must contain exactly one capture group {} which can span multiple path segments or be part of a single segment.

func (*Template) Match

func (c *Template) Match(path string) (*MatchResult, bool)

Match attempts to match the provided path against the template. If the path matches, it returns the MatchResult and true. Otherwise, it returns nil and false.

Jump to

Keyboard shortcuts

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