Documentation ¶
Overview ¶
Package resourcepaths parses API and other resource paths.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // AllowWildcard indicates whether the parser should allow wildcard segments. AllowWildcard bool // AllowFallback indicates whether the parser should allow fallback segments. AllowFallback bool // PrefixSlash indicates whether the parser should require a leading slash // or require that it's not present PrefixSlash bool }
type Path ¶
Path represents a parsed path.
func Parse ¶
func Parse(errs *perr.List, startPos token.Pos, path string, options Options) (parsedPath *Path, ok bool)
Parse parses a slash-separated path into path segments.
strPos is the position of where the path string was found in the source code.
func (*Path) HasFallback ¶ added in v1.16.1
HasFallback is true if the path contains a fallback segment.
func (*Path) NumParams ¶
NumParams reports the number of parameterized (non-literal) segments in the path.
type Segment ¶
type Segment struct { Type SegmentType Value string // literal if Type == Literal; name of parameter otherwise ValueType schema.BuiltinKind StartPos token.Pos EndPos token.Pos }
Segment represents a parsed path segment.
type SegmentType ¶
type SegmentType int
SegmentType represents the different types of path segments recognized by the parser.
const ( // Literal is a literal string path segment. Literal SegmentType = iota // Param represents a single path segment of any (non-empty) value. Param // Wildcard represents zero or more path segments of any value. Wildcard // Fallback represents zero or more path segments of any value // that are lower priority than any other path. Fallback )
Click to show internal directories.
Click to hide internal directories.