paths

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MPL-2.0 Imports: 6 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
}

Path represents a parsed path.

func Parse

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

Parse parses a rooted path (starting with '/') 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.

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.

Jump to

Keyboard shortcuts

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