matcher

package
v0.0.88 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasLeadingSlash

func HasLeadingSlash(pattern string) bool

func HasTrailingSlash

func HasTrailingSlash(pattern string) bool

func JoinPatterns

func JoinPatterns(rp *RegisteredPattern, pattern string) string

func ParseSegments

func ParseSegments(path string) []string

Types

type FindNestedMatchesResults

type FindNestedMatchesResults struct {
	Params      Params
	SplatValues []string
	Matches     []*Match
}

type Match

type Match struct {
	*RegisteredPattern
	Params      Params
	SplatValues []string
	// contains filtered or unexported fields
}

type Matcher

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

func New

func New(opts *Options) *Matcher

func (*Matcher) FindBestMatch

func (m *Matcher) FindBestMatch(realPath string) (*Match, bool)

func (*Matcher) FindNestedMatches

func (m *Matcher) FindNestedMatches(realPath string) (*FindNestedMatchesResults, bool)

func (*Matcher) Log

func (m *Matcher) Log(msg string)

func (*Matcher) NormalizePattern

func (m *Matcher) NormalizePattern(originalPattern string) *RegisteredPattern

func (*Matcher) RegisterPattern

func (m *Matcher) RegisterPattern(originalPattern string) *RegisteredPattern

type Options

type Options struct {
	DynamicParamPrefixRune rune // Optional. Defaults to ':'.
	SplatSegmentRune       rune // Optional. Defaults to '*'.

	// Optional. Defaults to empty string (effectively a trailing slash in the pattern).
	// Could also be something like "_index" if preferred by the user.
	ExplicitIndexSegment string

	Quiet bool // Optional. Defaults to false. Set to true if you want to quash warnings.
}

type Params

type Params = map[string]string

type RegisteredPattern

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

func (*RegisteredPattern) NormalizedPattern

func (rp *RegisteredPattern) NormalizedPattern() string

func (*RegisteredPattern) NormalizedSegments

func (rp *RegisteredPattern) NormalizedSegments() []*segment

func (*RegisteredPattern) OriginalPattern

func (rp *RegisteredPattern) OriginalPattern() string

Jump to

Keyboard shortcuts

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