paths

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package paths parses API paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConflictError

type ConflictError struct {
	Path    *Path
	Other   *Path
	Context string
}

ConflictError represents a conflict between two paths.

func (*ConflictError) Error

func (e *ConflictError) Error() string

type Path

type Path struct {
	Pos      token.Pos
	Segments []Segment
	Type     Type
}

Path represents a parsed path.

func Parse

func Parse(pos token.Pos, path string, typ Type) (*Path, error)

Parse parses a slash-separated path into path segments.

func (*Path) NumParams

func (p *Path) NumParams() int

NumParams reports the number of parameterized (non-literal) segments in the path.

func (*Path) String

func (p *Path) String() string

String returns the path's string representation.

func (*Path) ToProto added in v1.7.0

func (p *Path) ToProto() *meta.Path

type Segment

type Segment struct {
	Type      SegmentType
	Value     string // literal if Type == Literal; name of parameter otherwise
	ValueType schema.Builtin
}

Segment represents a parsed path segment.

func (*Segment) String

func (s *Segment) String() string

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 reprsents zero or more path segments of any value.
	Wildcard
)

type Set

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

Set tracks a set of paths, ensuring they are compatible with each other. The zero value is ready to use.

func (*Set) Add

func (s *Set) Add(method string, path *Path) error

Add adds a path to the set of paths. Errors are always of type *ConflictError.

type Type added in v1.7.0

type Type int
const (
	URL           Type = 0
	CacheKeyspace Type = 1
)

func (Type) LeadingSlash added in v1.7.0

func (t Type) LeadingSlash() bool

func (Type) SupportsWildcards added in v1.7.0

func (t Type) SupportsWildcards() bool

Jump to

Keyboard shortcuts

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