httprule

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type FieldPath

type FieldPath []string

FieldPath describes the path for a field from a message. Individual segments are in snake case (same as in protobuf file).

func (FieldPath) String

func (f FieldPath) String() string

type Rule

type Rule struct {
	// The HTTP method to use.
	Method string
	// The template describing the URL to use.
	Template        Template
	Body            string
	AdditionalRules []Rule
}

func ParseRule

func ParseRule(httpRule *annotations.HttpRule) (Rule, error)

type Segment

type Segment struct {
	Kind     SegmentKind
	Literal  string
	Variable VariableSegment
}

Segment represents a single segment of a Template.

type SegmentKind

type SegmentKind int
const (
	SegmentKindLiteral SegmentKind = iota
	SegmentKindMatchSingle
	SegmentKindMatchMultiple
	SegmentKindVariable
)

type Template

type Template struct {
	Segments []Segment
	Verb     string
}

Template represents a http path template.

Example: `/v1/{name=books/*}:publish`.

func ParseTemplate

func ParseTemplate(s string) (Template, error)

type VariableSegment

type VariableSegment struct {
	FieldPath FieldPath
	Segments  []Segment
}

VariableSegment represents a variable segment.

Jump to

Keyboard shortcuts

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