From bccb0382d886b1f7a7db75f7acd78d4b47e44ab2 Mon Sep 17 00:00:00 2001 From: what Date: Tue, 26 Nov 2024 17:00:24 +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 9b72ab2..fb34bb1 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 ..._RouteFilter) (HttpResponse, error) - Get(uuid string, opts ..._RouteFilter) (Route, bool) + Call(r *http.Request, code string, params map[string]any, opts ...RouteFilterOption) (HttpResponse, error) + Get(uuid string, opts ...RouteFilterOption) (Route, bool) Register(cr chi.Router) RefreshRoutes() error } @@ -108,22 +108,22 @@ type RouteParam interface { InjectRequestToGlobalParams(*http.Request, GlobalParams) error } -type _RouteFilter func(opts *RouteFilterOption) -type RouteFilterOption struct { +type RouteFilterOption func(opts *RouteFilterOptions) +type RouteFilterOptions struct { categories []RouteCategory services []RouteService } -func (this RouteFilterOption) RouteCategories() []RouteCategory { +func (this RouteFilterOptions) RouteCategories() []RouteCategory { return this.categories } -func (this RouteFilterOption) RouteServices() []RouteService { +func (this RouteFilterOptions) RouteServices() []RouteService { return this.services } -func RouteFilter[T RouteCategory | RouteService](v T) _RouteFilter { - return func(opt *RouteFilterOption) { +func RouteFilter[T RouteCategory | RouteService](v T) RouteFilterOption { + return func(opt *RouteFilterOptions) { switch value := any(v).(type) { case RouteCategory: opt.categories = append(opt.categories, value)