From daa6f650ab186db5eb79d131f04640ef910dc740 Mon Sep 17 00:00:00 2001 From: EwenQuim Date: Tue, 17 Dec 2024 15:34:46 +0100 Subject: [PATCH] Remove NewBaseRoute function and use fuego.NewBaseRoute instead --- extra/fuegogin/adaptor.go | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/extra/fuegogin/adaptor.go b/extra/fuegogin/adaptor.go index dec120b7..d5f7ac0a 100644 --- a/extra/fuegogin/adaptor.go +++ b/extra/fuegogin/adaptor.go @@ -3,7 +3,6 @@ package fuegogin import ( "log/slog" - "github.com/getkin/kin-openapi/openapi3" "github.com/gin-gonic/gin" "github.com/go-fuego/fuego" @@ -26,12 +25,12 @@ func Post[T, B any](s *fuego.OpenAPI, e gin.IRouter, path string, handler func(c } func handleFuego[T, B any](openapi *fuego.OpenAPI, e gin.IRouter, method, path string, fuegoHandler func(c ContextWithBody[B]) (T, error), options ...func(*fuego.BaseRoute)) *fuego.Route[T, B] { - baseRoute := NewBaseRoute(method, path, fuegoHandler, openapi, options...) + baseRoute := fuego.NewBaseRoute(method, path, fuegoHandler, openapi, options...) return handle(openapi, e, &fuego.Route[T, B]{BaseRoute: baseRoute}, GinHandler(fuegoHandler)) } func handleGin(openapi *fuego.OpenAPI, e gin.IRouter, method, path string, ginHandler gin.HandlerFunc, options ...func(*fuego.BaseRoute)) *fuego.Route[any, any] { - baseRoute := NewBaseRoute(method, path, ginHandler, openapi, options...) + baseRoute := fuego.NewBaseRoute(method, path, ginHandler, openapi, options...) return handle(openapi, e, &fuego.Route[any, any]{BaseRoute: baseRoute}, ginHandler) } @@ -50,23 +49,6 @@ func handle[T, B any](openapi *fuego.OpenAPI, e gin.IRouter, route *fuego.Route[ return route } -func NewBaseRoute(method, path string, handler any, openapi *fuego.OpenAPI, options ...func(*fuego.BaseRoute)) fuego.BaseRoute { - baseRoute := fuego.BaseRoute{ - Method: method, - Path: path, - Params: make(map[string]fuego.OpenAPIParam), - FullName: fuego.FuncName(handler), - Operation: openapi3.NewOperation(), - OpenAPI: openapi, - } - - for _, o := range options { - o(&baseRoute) - } - - return baseRoute -} - // Convert a Fuego handler to a Gin handler. func GinHandler[B, T any](handler func(c ContextWithBody[B]) (T, error)) gin.HandlerFunc { return func(c *gin.Context) {