diff options
Diffstat (limited to 'backend/api/handler_wrapper.go')
| -rw-r--r-- | backend/api/handler_wrapper.go | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/backend/api/handler_wrapper.go b/backend/api/handler_wrapper.go index 681b064..95e6d2b 100644 --- a/backend/api/handler_wrapper.go +++ b/backend/api/handler_wrapper.go @@ -17,11 +17,11 @@ type HandlerWrapper struct { impl Handler } -func NewHandler(queries *db.Queries, hubs GameHubsInterface) *HandlerWrapper { +func NewHandler(queries *db.Queries, hub GameHubInterface) *HandlerWrapper { return &HandlerWrapper{ impl: Handler{ - q: queries, - hubs: hubs, + q: queries, + hub: hub, }, } } @@ -51,6 +51,42 @@ func (h *HandlerWrapper) GetGame(ctx context.Context, request GetGameRequestObje return h.impl.GetGame(ctx, request, user) } +func (h *HandlerWrapper) GetGamePlayLatestState(ctx context.Context, request GetGamePlayLatestStateRequestObject) (GetGamePlayLatestStateResponseObject, error) { + user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization) + if err != nil { + return GetGamePlayLatestState401JSONResponse{ + UnauthorizedJSONResponse: UnauthorizedJSONResponse{ + Message: "Unauthorized", + }, + }, nil + } + return h.impl.GetGamePlayLatestState(ctx, request, user) +} + +func (h *HandlerWrapper) GetGameWatchLatestStates(ctx context.Context, request GetGameWatchLatestStatesRequestObject) (GetGameWatchLatestStatesResponseObject, error) { + user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization) + if err != nil { + return GetGameWatchLatestStates401JSONResponse{ + UnauthorizedJSONResponse: UnauthorizedJSONResponse{ + Message: "Unauthorized", + }, + }, nil + } + return h.impl.GetGameWatchLatestStates(ctx, request, user) +} + +func (h *HandlerWrapper) GetGameWatchRanking(ctx context.Context, request GetGameWatchRankingRequestObject) (GetGameWatchRankingResponseObject, error) { + user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization) + if err != nil { + return GetGameWatchRanking401JSONResponse{ + UnauthorizedJSONResponse: UnauthorizedJSONResponse{ + Message: "Unauthorized", + }, + }, nil + } + return h.impl.GetGameWatchRanking(ctx, request, user) +} + func (h *HandlerWrapper) GetGames(ctx context.Context, request GetGamesRequestObject) (GetGamesResponseObject, error) { user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization) if err != nil { @@ -63,16 +99,28 @@ func (h *HandlerWrapper) GetGames(ctx context.Context, request GetGamesRequestOb return h.impl.GetGames(ctx, request, user) } -func (h *HandlerWrapper) GetToken(ctx context.Context, request GetTokenRequestObject) (GetTokenResponseObject, error) { +func (h *HandlerWrapper) PostGamePlayCode(ctx context.Context, request PostGamePlayCodeRequestObject) (PostGamePlayCodeResponseObject, error) { + user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization) + if err != nil { + return PostGamePlayCode401JSONResponse{ + UnauthorizedJSONResponse: UnauthorizedJSONResponse{ + Message: "Unauthorized", + }, + }, nil + } + return h.impl.PostGamePlayCode(ctx, request, user) +} + +func (h *HandlerWrapper) PostGamePlaySubmit(ctx context.Context, request PostGamePlaySubmitRequestObject) (PostGamePlaySubmitResponseObject, error) { user, err := parseJWTClaimsFromAuthorizationHeader(request.Params.Authorization) if err != nil { - return GetToken401JSONResponse{ + return PostGamePlaySubmit401JSONResponse{ UnauthorizedJSONResponse: UnauthorizedJSONResponse{ Message: "Unauthorized", }, }, nil } - return h.impl.GetToken(ctx, request, user) + return h.impl.PostGamePlaySubmit(ctx, request, user) } func (h *HandlerWrapper) PostLogin(ctx context.Context, request PostLoginRequestObject) (PostLoginResponseObject, error) { |
