From ff67ba5bf000bac422bb4704cd4f7bcc2faa0417 Mon Sep 17 00:00:00 2001 From: Mark Bailey Date: Sat, 6 Sep 2025 18:11:20 -0400 Subject: [PATCH] refactor: return pointer to router/route info --- routing.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/routing.go b/routing.go index 80887b6..09727a6 100644 --- a/routing.go +++ b/routing.go @@ -20,13 +20,13 @@ type RouteInfo struct { Title string } -func NewRouteInfo(method, path, description, title string) (RouteInfo, error) { +func NewRouteInfo(method, path, description, title string) (*RouteInfo, error) { name, err := convertRouteToRouteName(path) if err != nil { - return RouteInfo{}, err + return &RouteInfo{}, err } - return RouteInfo{ + return &RouteInfo{ Method: method, Name: name, Path: path, @@ -43,7 +43,7 @@ type Router struct { cacheTTL time.Duration } -func NewRouter() Router { +func NewRouter() *Router { ttl := 8 * time.Hour cache, err := NewRouteCacheService(WithTTL(ttl)) @@ -51,7 +51,7 @@ func NewRouter() Router { log.Fatal(jerr.Wrap(err, jerr.ErrRouterNotCreated)) } - return Router{cache: cache, cacheTTL: ttl} + return &Router{cache: cache, cacheTTL: ttl} } func (ro *Router) WithRouteInfo(ri RouteInfo, h HandlerFn) http.HandlerFunc {