Documentation ¶
Overview ¶
Package routematch is for route match operation
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoMatched = errors.New("no matched route pattern")
ErrNoMatched no matched route pattern
Functions ¶
This section is empty.
Types ¶
type Route ¶
type Route struct { // Method is http method, eg: GET, POST, PUT, DELETE Method string // Pattern is path pattern, eg: /api/v1/config/biz/{biz_id}/apps/{app_id} Pattern string }
Route is route object
type RouteMatcher ¶
type RouteMatcher struct {
// contains filtered or unexported fields
}
RouteMatcher is route matcher
func (*RouteMatcher) Match ¶
func (m *RouteMatcher) Match(method, path string) (string, error)
Match 获取最长匹配的路由pattern eg: method相同的情况下,/api/v1/config/biz/{biz_id}/apps/{app_id} 可匹配 /api/v1/config/biz/2/apps/1
func (*RouteMatcher) PatternMap ¶
func (m *RouteMatcher) PatternMap() map[string]string
PatternMap return patternMap of RouteMatcher
func (*RouteMatcher) RouteMap ¶
func (m *RouteMatcher) RouteMap() map[string][]string
RouteMap return routemap of RouteMatcher
Click to show internal directories.
Click to hide internal directories.