diff options
Diffstat (limited to 'backend/api')
| -rw-r--r-- | backend/api/handler.go (renamed from backend/api/handlers.go) | 13 | ||||
| -rw-r--r-- | backend/api/handler_wrapper.go | 4 | ||||
| -rw-r--r-- | backend/api/workaround.go | 2 |
3 files changed, 9 insertions, 10 deletions
diff --git a/backend/api/handlers.go b/backend/api/handler.go index 659e5c1..57d7464 100644 --- a/backend/api/handlers.go +++ b/backend/api/handler.go @@ -12,7 +12,7 @@ import ( "github.com/nsfisis/iosdc-japan-2024-albatross/backend/db" ) -type ApiHandler struct { +type Handler struct { q *db.Queries hubs GameHubsInterface } @@ -21,7 +21,7 @@ type GameHubsInterface interface { StartGame(gameID int) error } -func (h *ApiHandler) PostLogin(ctx context.Context, request PostLoginRequestObject) (PostLoginResponseObject, error) { +func (h *Handler) PostLogin(ctx context.Context, request PostLoginRequestObject) (PostLoginResponseObject, error) { username := request.Body.Username password := request.Body.Password userID, err := auth.Login(ctx, h.q, username, password) @@ -52,7 +52,7 @@ func (h *ApiHandler) PostLogin(ctx context.Context, request PostLoginRequestObje }, nil } -func (h *ApiHandler) GetToken(ctx context.Context, request GetTokenRequestObject, user *auth.JWTClaims) (GetTokenResponseObject, error) { +func (h *Handler) GetToken(_ context.Context, _ GetTokenRequestObject, user *auth.JWTClaims) (GetTokenResponseObject, error) { newToken, err := auth.NewShortLivedJWT(user) if err != nil { return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -62,7 +62,7 @@ func (h *ApiHandler) GetToken(ctx context.Context, request GetTokenRequestObject }, nil } -func (h *ApiHandler) GetGames(ctx context.Context, request GetGamesRequestObject, user *auth.JWTClaims) (GetGamesResponseObject, error) { +func (h *Handler) GetGames(ctx context.Context, _ GetGamesRequestObject, user *auth.JWTClaims) (GetGamesResponseObject, error) { gameRows, err := h.q.ListGamesForPlayer(ctx, int32(user.UserID)) if err != nil { return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -100,7 +100,7 @@ func (h *ApiHandler) GetGames(ctx context.Context, request GetGamesRequestObject }, nil } -func (h *ApiHandler) GetGame(ctx context.Context, request GetGameRequestObject, user *auth.JWTClaims) (GetGameResponseObject, error) { +func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, user *auth.JWTClaims) (GetGameResponseObject, error) { // TODO: check user permission gameID := request.GameID row, err := h.q.GetGameByID(ctx, int32(gameID)) @@ -111,9 +111,8 @@ func (h *ApiHandler) GetGame(ctx context.Context, request GetGameRequestObject, Message: "Game not found", }, }, nil - } else { - return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } + return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } var startedAt *int if row.StartedAt.Valid { diff --git a/backend/api/handler_wrapper.go b/backend/api/handler_wrapper.go index fdee581..69b9baa 100644 --- a/backend/api/handler_wrapper.go +++ b/backend/api/handler_wrapper.go @@ -14,12 +14,12 @@ import ( var _ StrictServerInterface = (*ApiHandlerWrapper)(nil) type ApiHandlerWrapper struct { - innerHandler ApiHandler + innerHandler Handler } func NewHandler(queries *db.Queries, hubs GameHubsInterface) *ApiHandlerWrapper { return &ApiHandlerWrapper{ - innerHandler: ApiHandler{ + innerHandler: Handler{ q: queries, hubs: hubs, }, diff --git a/backend/api/workaround.go b/backend/api/workaround.go index a3c47d7..5b5fe59 100644 --- a/backend/api/workaround.go +++ b/backend/api/workaround.go @@ -12,7 +12,7 @@ func GetSwaggerWithPrefix(prefix string) (*openapi3.T, error) { return nil, err } - var prefixedPaths openapi3.Paths = openapi3.Paths{} + prefixedPaths := openapi3.Paths{} for key, value := range spec.Paths.Map() { prefixedPaths.Set(prefix+key, value) } |
