Documentation
¶
Overview ¶
Package matcher provides route-level middleware selection: it maps a transport operation (gRPC full method or "METHOD /path") to the middlewares that apply to it, so different endpoints can carry different cross-cutting concerns (e.g. rate limiting only under /admin/*). It is inspired by kratos' internal matcher and is transport-agnostic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Match ¶
func Match(m *Matcher) middleware.Middleware
Match returns a unified Middleware that, per request, selects the middlewares applying to the current transport operation (gRPC full method or "METHOD /path") and chains them around next. It composes with the existing middleware.UnaryServerInterceptor and middleware.GinHandler bridges, so a single matcher serves both protocols.
Types ¶
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher selects middlewares by operation. Use registers global defaults; Add registers middlewares for a selector. Selectors are either an exact operation ("/pkg.Service/Method"), a prefix ending in "*" ("/pkg.Service/*"), or "*" for every operation.
func (*Matcher) Add ¶
func (m *Matcher) Add(selector string, mws ...middleware.Middleware) *Matcher
Add registers middlewares for a selector, returning m for chaining.
func (*Matcher) Match ¶
func (m *Matcher) Match(operation string) []middleware.Middleware
Match returns the middlewares applying to operation: defaults first, then an exact match, then prefix matches from longest to shortest prefix.
func (*Matcher) Use ¶
func (m *Matcher) Use(mws ...middleware.Middleware) *Matcher
Use appends global middlewares applied to every operation, outermost first.