From f9d7439defb8ec9c3fc703b145aef60d9c597b5f Mon Sep 17 00:00:00 2001 From: Nikolai Papin Date: Thu, 17 Jul 2025 17:52:12 +0300 Subject: [PATCH] fix: Setup interface mismatch; refactor: GetRequest now panics on missing client_info since it is only supposed to be used on handlers behind AuthMiddleware --- backend/internal/controllers/controller.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/internal/controllers/controller.go b/backend/internal/controllers/controller.go index 9686bec..15e9195 100644 --- a/backend/internal/controllers/controller.go +++ b/backend/internal/controllers/controller.go @@ -19,7 +19,6 @@ package controllers import ( "easywish/internal/dto" - errs "easywish/internal/errors" "easywish/internal/middleware" "easywish/internal/services" "easywish/internal/utils/enums" @@ -105,7 +104,7 @@ func (ctrl *controllerImpl) Setup(group *gin.RouterGroup, log *zap.Logger, auth } type Controller interface { - Setup() + Setup(group *gin.RouterGroup, log *zap.Logger, auth services.AuthService) } func GetRequest[ModelT any](c *gin.Context) (*dto.Request[ModelT], error) { @@ -116,6 +115,7 @@ func GetRequest[ModelT any](c *gin.Context) (*dto.Request[ModelT], error) { return nil, err } + // TODO: Think hard on a singleton for better performance validate := validation.NewValidator() if err := validate.Struct(body); err != nil { @@ -130,7 +130,7 @@ func GetRequest[ModelT any](c *gin.Context) (*dto.Request[ModelT], error) { c.AbortWithStatusJSON( http.StatusInternalServerError, gin.H{"error": "Client info was not found"}) - return nil, errs.ErrClientInfoNotProvided + panic("No client_info found in gin context. Does the handler use AuthMiddleware?") } cinfo := cinfoFromCtx.(*dto.ClientInfo)