From f1774e5ca2f0323f894e08c881e9e7ee70fed4e4 Mon Sep 17 00:00:00 2001 From: what Date: Tue, 26 Nov 2024 17:35:11 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E5=AE=8C=E5=96=84=20Router.Call=20Rou?= =?UTF-8?q?ter.Get=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routing.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/routing.go b/routing.go index fb34bb1..198bd13 100755 --- a/routing.go +++ b/routing.go @@ -80,8 +80,8 @@ type RouteMiddleware interface { } type Router interface { - Call(r *http.Request, code string, params map[string]any, opts ...RouteFilterOption) (HttpResponse, error) - Get(uuid string, opts ...RouteFilterOption) (Route, bool) + Call(r *http.Request, code string, params map[string]any, opts ...RouteMatchOption) (HttpResponse, error) + Get(uuid string, opts ...RouteMatchOption) (Route, bool) Register(cr chi.Router) RefreshRoutes() error } @@ -108,22 +108,22 @@ type RouteParam interface { InjectRequestToGlobalParams(*http.Request, GlobalParams) error } -type RouteFilterOption func(opts *RouteFilterOptions) -type RouteFilterOptions struct { +type RouteMatchOption func(opts *RouteMatches) +type RouteMatches struct { categories []RouteCategory services []RouteService } -func (this RouteFilterOptions) RouteCategories() []RouteCategory { +func (this RouteMatches) RouteCategories() []RouteCategory { return this.categories } -func (this RouteFilterOptions) RouteServices() []RouteService { +func (this RouteMatches) RouteServices() []RouteService { return this.services } -func RouteFilter[T RouteCategory | RouteService](v T) RouteFilterOption { - return func(opt *RouteFilterOptions) { +func RouteMatch[T RouteCategory | RouteService](v T) RouteMatchOption { + return func(opt *RouteMatches) { switch value := any(v).(type) { case RouteCategory: opt.categories = append(opt.categories, value)