url

package
v1.135.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicEqualityPathSegmentMatcher

func BasicEqualityPathSegmentMatcher(segmentA, segmentB string) (match bool, err error)

BasicEqualityPathSegmentMatcher is a PathSegmentMatcherFunc that performs direct string comparison of two path segments.

func BasicEqualityPathSegmentWithParamMatcher

func BasicEqualityPathSegmentWithParamMatcher(segmentA, segmentB string) (match bool, err error)

BasicEqualityPathSegmentWithParamMatcher is a PathSegmentMatcherFunc that is similar to BasicEqualityPathSegmentMatcher but accounts for path parameter segments.

func HasMatchingPathSegments

func HasMatchingPathSegments(pathA, pathB string) (match bool, err error)

HasMatchingPathSegments checks whether two path strings match based on their segments by doing a simple equality check on each path segment pair.

func HasMatchingPathSegmentsWithParams

func HasMatchingPathSegmentsWithParams(pathA, pathB string) (match bool, err error)

HasMatchingPathSegmentsWithParams is similar to HasMatchingPathSegments but also considers segments as matching if at least one of them contains a path parameter.

HasMatchingPathSegmentsWithParams("/some/{param}/path", "/some/{param}/path") // true
HasMatchingPathSegmentsWithParams("/some/abc/path", "/some/{param}/path") // true
HasMatchingPathSegmentsWithParams("/some/abc/path", "/some/def/path") // false

func MatchesPathParameterSyntax

func MatchesPathParameterSyntax(parameter string) bool

MatchesPathParameterSyntax checks whether the parameter string matches the syntax for a path parameter as described by the OpenAPI spec (see https://spec.openapis.org/oas/v3.0.0.html#path-templating).

func MatchingPathSegments

func MatchingPathSegments(pathA, pathB string, matcherFn PathSegmentMatcherFunc) (match bool, err error)

MatchingPathSegments checks whether two path strings match based on their segments using the provided matcher function.

func SplitPath

func SplitPath(p string) []string

SplitPath returns a slice containing the individual segments that make up the path string p. It looks for the default forward slash path separator when splitting.

func ValidatePathParameter

func ValidatePathParameter(parameter string) error

ValidatePathParameter checks whether a path parameter is valid. An error is returned if it is invalid. Version 3.1.0 of the OpenAPI spec provides some guidance for path parameter values (see https://spec.openapis.org/oas/v3.1.0.html#path-templating)

Types

type PathSegmentMatcherFunc

type PathSegmentMatcherFunc = func(segmentA, segmentB string) (match bool, err error)

PathSegmentMatcherFunc defines the signature for path segment matcher functions.

Jump to

Keyboard shortcuts

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