route

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotFoundRoute = &Route{
		Path:   "/",
		Router: &Router{To: ToNotFound},
	}
)

Functions

func IsComparable

func IsComparable(v any) bool

Types

type PathMatcher

type PathMatcher struct {
	Values map[string]string
	// contains filtered or unexported fields
}

func NewPathMatcher

func NewPathMatcher(expr string) (*PathMatcher, error)

func (*PathMatcher) Match

func (p *PathMatcher) Match(path string) bool

func (*PathMatcher) SetValue

func (p *PathMatcher) SetValue(key, value string)

type Route

type Route struct {
	Path      string                       `json:"path" yaml:"path"`
	PathRegex string                       `json:"pathRegex" yaml:"pathRegex"`
	Method    string                       `json:"method" yaml:"method"`
	Router    *Router                      `json:"router" yaml:"router"`
	Filters   []*reverseproxy.FilterConfig `json:"filters" yaml:"filters"`

	PathMatcher   *PathMatcher             `json:"-" yaml:"-"`
	MethodMatcher func(method string) bool `json:"-" yaml:"-"`
}

func (*Route) Clone

func (r *Route) Clone() *Route

func (*Route) Director

func (r *Route) Director(ctx context.Context) func(req *http.Request)

func (*Route) HandlerWith

func (r *Route) HandlerWith(ctx context.Context, kvs ...any) http.HandlerFunc

func (*Route) IsNotFoundRoute

func (r *Route) IsNotFoundRoute() bool

func (*Route) Match

func (r *Route) Match(path, method string) bool

func (*Route) OverridePathRegex

func (r *Route) OverridePathRegex()

OverridePathRegex generates the PathRegex and overwrite it

func (*Route) PathRegexExpr

func (r *Route) PathRegexExpr() string

func (*Route) Validate

func (r *Route) Validate() error

type Router

type Router struct {
	To         To     `json:"to" yaml:"to"`
	InstanceId string `json:"instanceId" yaml:"instanceId"`
	Scheme     string `json:"scheme" yaml:"scheme"`
	Host       string `json:"host" yaml:"host"`
	Rewrite    string `json:"rewrite" yaml:"rewrite"`
}

func (*Router) Clone

func (r *Router) Clone() *Router

func (*Router) Director

func (r *Router) Director(ctx context.Context, metadata map[string]string) func(r *http.Request)

func (*Router) RewritePath

func (r *Router) RewritePath(path string, metadata map[string]string) string

type Routes

type Routes []*Route

func (Routes) FindRoute

func (routes Routes) FindRoute(req *http.Request) *Route

func (Routes) Validate

func (routes Routes) Validate() error

type To

type To string
const (
	ToURL      To = "__url__"
	ToNotFound To = "__not_found__"
)

Jump to

Keyboard shortcuts

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