httprule

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package httprule contains utilities to describe HTTP route rules and is used by the configs and the code generators to prepare HTTP routes.

This is a package mostly useful for gateway mux developers and other internal tools. Unless you are building a gRPC gateway serve mux or tooling related to the gateway, do not use these packages. These packages are indirectly used when you use the code generator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Segment

type Segment struct {
	// Value holds string value and is contextualized based on segment type.
	Value string

	// Type describes the type of HTTP rule segment.
	Type SegmentType
}

Segment is an HTTP rule path segment.

type SegmentType

type SegmentType uint8

SegmentType is the type of path segment in the HTTP rule.

const (
	SegmentTypeLiteral          SegmentType = iota // SegmentTypeLiteral is a literal string.
	SegmentTypeSelector                            // SegmentTypeSelector is a variable.
	SegmentTypeCatchAllSelector                    // SegmentTypeCatchAllSelector is similar to selector but reads everything.
)

type Template

type Template struct {
	// Segments contains all of the path segments.
	Segments []Segment
}

Template is an HTTP rule template that can be used to build out routes.

func Parse

func Parse(path string) (Template, error)

Parse parses an HTTP rule syntax and builds out a template.

func (Template) HasVariables

func (t Template) HasVariables() bool

HasVariables returns whether or not the current template contains any binding variables.

func (Template) Pattern

func (t Template) Pattern() string

Pattern returns a string representation without variable names. Can be used to compare two templates.

func (Template) String

func (t Template) String() string

Jump to

Keyboard shortcuts

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