http_router

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const All = "*"

Variables

View Source
var ErrorDuplicate = errors.New("duplicate")

Functions

func Key

func Key(rules []AppendRule) string

Types

type AppendMatcher

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

func (*AppendMatcher) Match

func (a *AppendMatcher) Match(port int, request http_service.IRequestReader) (IRouterHandler, bool)

type AppendMatchers

type AppendMatchers []*AppendMatcher

func (AppendMatchers) Len

func (as AppendMatchers) Len() int

func (AppendMatchers) Less

func (as AppendMatchers) Less(i, j int) bool

func (AppendMatchers) Match

func (as AppendMatchers) Match(port int, request http_service.IRequestReader) (IRouterHandler, bool)

func (AppendMatchers) Swap

func (as AppendMatchers) Swap(i, j int)

type AppendRule

type AppendRule struct {
	Type    string
	Name    string
	Pattern string
}

type AppendRules

type AppendRules []AppendRule

func (AppendRules) Len

func (as AppendRules) Len() int

func (AppendRules) Less

func (as AppendRules) Less(i, j int) bool

func (AppendRules) Swap

func (as AppendRules) Swap(i, j int)

type CheckMatcher

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

func NewPathMatcher

func NewPathMatcher(equals map[string]IMatcher, checkers []*CheckerHandler, all IMatcher) *CheckMatcher

func (*CheckMatcher) Match

func (c *CheckMatcher) Match(port int, request http_service.IRequestReader) (IRouterHandler, bool)

type CheckerHandler

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

type CheckerSort

type CheckerSort []*CheckerHandler

func (CheckerSort) Len

func (cs CheckerSort) Len() int

func (CheckerSort) Less

func (cs CheckerSort) Less(i, j int) bool

func (CheckerSort) Swap

func (cs CheckerSort) Swap(i, j int)

type CookieChecker

type CookieChecker struct {
	checker.Checker
	// contains filtered or unexported fields
}

func (*CookieChecker) MatchCheck

func (c *CookieChecker) MatchCheck(request http_service.IRequestReader) bool

type EmptyChecker

type EmptyChecker struct {
}

func (*EmptyChecker) MatchCheck

func (e *EmptyChecker) MatchCheck(request http_service.IRequestReader) bool

type EmptyMatcher

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

func (*EmptyMatcher) Match

func (e *EmptyMatcher) Match(port int, request http_service.IRequestReader) (IRouterHandler, bool)

type Handler

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

func NewHandler

func NewHandler(id string, handler IRouterHandler, appends []AppendRule) *Handler

func (*Handler) Build

func (h *Handler) Build() IMatcher

type HeaderChecker

type HeaderChecker struct {
	checker.Checker
	// contains filtered or unexported fields
}

func (*HeaderChecker) MatchCheck

func (h *HeaderChecker) MatchCheck(request http_service.IRequestReader) bool

type Hosts

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

func NewHosts

func NewHosts() *Hosts

func (*Hosts) Add

func (h *Hosts) Add(id string, handler IRouterHandler, methods []string, path string, append []AppendRule) error

func (*Hosts) Build

func (h *Hosts) Build() IMatcher

type IBuilder

type IBuilder interface {
	Build() IMatcher
}

type IMatcher

type IMatcher interface {
	Match(port int, request http_service.IRequestReader) (IRouterHandler, bool)
}

type IRouterHandler

type IRouterHandler interface {
	ServeHTTP(ctx eoscContext.EoContext)
}

type MatcherChecker

type MatcherChecker interface {
	MatchCheck(request http_service.IRequestReader) bool
	// contains filtered or unexported methods
}

func Parse

func Parse(rules []AppendRule) MatcherChecker

type MatcherCheckerItem

type MatcherCheckerItem interface {
	checker.Checker
	MatcherChecker
}

type Methods

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

func NewMethods

func NewMethods() *Methods

func (*Methods) Add

func (m *Methods) Add(id string, handler IRouterHandler, path string, append []AppendRule) error

func (*Methods) Build

func (m *Methods) Build() IMatcher

type Paths

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

func NewPaths

func NewPaths(checker checker.Checker) *Paths

func (*Paths) Add

func (p *Paths) Add(id string, handler IRouterHandler, append []AppendRule) error

func (*Paths) Build

func (p *Paths) Build() IMatcher

type Ports

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

func NewPorts

func NewPorts() *Ports

func (*Ports) Add

func (p *Ports) Add(id string, handler IRouterHandler, hosts []string, methods []string, path string, append []AppendRule) error

func (*Ports) Build

func (p *Ports) Build() IMatcher

type QueryChecker

type QueryChecker struct {
	checker.Checker
	// contains filtered or unexported fields
}

func (*QueryChecker) MatchCheck

func (q *QueryChecker) MatchCheck(request http_service.IRequestReader) bool

type Root

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

func NewRoot

func NewRoot() *Root

func (*Root) Add

func (r *Root) Add(id string, handler IRouterHandler, port int, hosts []string, methods []string, path string, append []AppendRule) error

func (*Root) Build

func (r *Root) Build() IMatcher

type RuleCheckers

type RuleCheckers []MatcherCheckerItem

func (RuleCheckers) Len

func (rs RuleCheckers) Len() int

func (RuleCheckers) Less

func (rs RuleCheckers) Less(i, j int) bool

func (RuleCheckers) MatchCheck

func (rs RuleCheckers) MatchCheck(request http_service.IRequestReader) bool

func (RuleCheckers) Swap

func (rs RuleCheckers) Swap(i, j int)

type RuleType

type RuleType = string
const (
	HttpHeader RuleType = "header"
	HttpQuery  RuleType = "query"
	HttpCookie RuleType = "cookie"
)

type SimpleMatcher

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

func (*SimpleMatcher) Match

func (s *SimpleMatcher) Match(port int, request http_service.IRequestReader) (IRouterHandler, bool)

Jump to

Keyboard shortcuts

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