ezrouter

package
v0.0.0-...-74e38f5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PatternRoute

type PatternRoute interface {
	Route
	GetPattern() string
	SetPattern(p string) error
}

type PlaceholderRoute

type PlaceholderRoute struct {
	// The HTTP method to filter on
	Method string

	// The placeholder pattern to match on e.g. /release/:releaseId
	Pattern string
	// contains filtered or unexported fields
}

You can use this to perform placeholder style routing such as "/article/:articleName". Valid placeholder patterns consist of characters A-z, 0-9, -, :, / and nothing else.

func (*PlaceholderRoute) GetPattern

func (r *PlaceholderRoute) GetPattern() string

func (*PlaceholderRoute) Match

func (r *PlaceholderRoute) Match(req *http.Request) *RouteMatches

func (*PlaceholderRoute) SetPattern

func (r *PlaceholderRoute) SetPattern(p string) error

type RegexpRoute

type RegexpRoute struct {
	Regexp *regexp.Regexp
}

func (*RegexpRoute) GetPattern

func (r *RegexpRoute) GetPattern() string

func (*RegexpRoute) Match

func (r *RegexpRoute) Match(req *http.Request) *RouteMatches

func (*RegexpRoute) SetPattern

func (r *RegexpRoute) SetPattern(p string) error

type Route

type Route interface {
	Match(r *http.Request) *RouteMatches
	GetHandler() func(interface{})
}

type RouteMatches

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

func (*RouteMatches) Add

func (m *RouteMatches) Add(name, value string)

func (*RouteMatches) All

func (m *RouteMatches) All() []string

func (*RouteMatches) AllNamed

func (m *RouteMatches) AllNamed() map[string]string

func (*RouteMatches) Index

func (m *RouteMatches) Index(i int) string

func (*RouteMatches) Named

func (m *RouteMatches) Named(name string) string

type StringRoute

type StringRoute struct {
	Method string
	Path   string
}

Use this for exact matching routes with string comparison. Very basic.

func (*StringRoute) GetPattern

func (r *StringRoute) GetPattern() string

func (*StringRoute) Match

func (r *StringRoute) Match(req *http.Request) *RouteMatches

func (*StringRoute) SetPattern

func (r *StringRoute) SetPattern(p string) error

Jump to

Keyboard shortcuts

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