diff options
Diffstat (limited to 'backend/api/generated.go')
| -rw-r--r-- | backend/api/generated.go | 140 |
1 files changed, 123 insertions, 17 deletions
diff --git a/backend/api/generated.go b/backend/api/generated.go index 922fb55..86e7567 100644 --- a/backend/api/generated.go +++ b/backend/api/generated.go @@ -114,6 +114,11 @@ type GetGamesParams struct { Authorization string `json:"Authorization"` } +// GetGamesGameIdParams defines parameters for GetGamesGameId. +type GetGamesGameIdParams struct { + Authorization string `json:"Authorization"` +} + // PostLoginJSONBody defines parameters for PostLogin. type PostLoginJSONBody struct { Password string `json:"password"` @@ -314,6 +319,9 @@ type ServerInterface interface { // List games // (GET /games) GetGames(ctx echo.Context, params GetGamesParams) error + // Get a game + // (GET /games/{game_id}) + GetGamesGameId(ctx echo.Context, gameId int, params GetGamesGameIdParams) error // User login // (POST /login) PostLogin(ctx echo.Context) error @@ -361,6 +369,44 @@ func (w *ServerInterfaceWrapper) GetGames(ctx echo.Context) error { return err } +// GetGamesGameId converts echo context to params. +func (w *ServerInterfaceWrapper) GetGamesGameId(ctx echo.Context) error { + var err error + // ------------- Path parameter "game_id" ------------- + var gameId int + + err = runtime.BindStyledParameterWithOptions("simple", "game_id", ctx.Param("game_id"), &gameId, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter game_id: %s", err)) + } + + // Parameter object where we will unmarshal all parameters from the context + var params GetGamesGameIdParams + + headers := ctx.Request().Header + // ------------- Required header parameter "Authorization" ------------- + if valueList, found := headers[http.CanonicalHeaderKey("Authorization")]; found { + var Authorization string + n := len(valueList) + if n != 1 { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Expected one value for Authorization, got %d", n)) + } + + err = runtime.BindStyledParameterWithOptions("simple", "Authorization", valueList[0], &Authorization, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter Authorization: %s", err)) + } + + params.Authorization = Authorization + } else { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Header parameter Authorization is required, but not found")) + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.GetGamesGameId(ctx, gameId, params) + return err +} + // PostLogin converts echo context to params. func (w *ServerInterfaceWrapper) PostLogin(ctx echo.Context) error { var err error @@ -399,6 +445,7 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL } router.GET(baseURL+"/games", wrapper.GetGames) + router.GET(baseURL+"/games/:game_id", wrapper.GetGamesGameId) router.POST(baseURL+"/login", wrapper.PostLogin) } @@ -433,6 +480,35 @@ func (response GetGames403JSONResponse) VisitGetGamesResponse(w http.ResponseWri return json.NewEncoder(w).Encode(response) } +type GetGamesGameIdRequestObject struct { + GameId int `json:"game_id"` + Params GetGamesGameIdParams +} + +type GetGamesGameIdResponseObject interface { + VisitGetGamesGameIdResponse(w http.ResponseWriter) error +} + +type GetGamesGameId200JSONResponse Game + +func (response GetGamesGameId200JSONResponse) VisitGetGamesGameIdResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(200) + + return json.NewEncoder(w).Encode(response) +} + +type GetGamesGameId403JSONResponse struct { + Message string `json:"message"` +} + +func (response GetGamesGameId403JSONResponse) VisitGetGamesGameIdResponse(w http.ResponseWriter) error { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(403) + + return json.NewEncoder(w).Encode(response) +} + type PostLoginRequestObject struct { Body *PostLoginJSONRequestBody } @@ -468,6 +544,9 @@ type StrictServerInterface interface { // List games // (GET /games) GetGames(ctx context.Context, request GetGamesRequestObject) (GetGamesResponseObject, error) + // Get a game + // (GET /games/{game_id}) + GetGamesGameId(ctx context.Context, request GetGamesGameIdRequestObject) (GetGamesGameIdResponseObject, error) // User login // (POST /login) PostLogin(ctx context.Context, request PostLoginRequestObject) (PostLoginResponseObject, error) @@ -510,6 +589,32 @@ func (sh *strictHandler) GetGames(ctx echo.Context, params GetGamesParams) error return nil } +// GetGamesGameId operation middleware +func (sh *strictHandler) GetGamesGameId(ctx echo.Context, gameId int, params GetGamesGameIdParams) error { + var request GetGamesGameIdRequestObject + + request.GameId = gameId + request.Params = params + + handler := func(ctx echo.Context, request interface{}) (interface{}, error) { + return sh.ssi.GetGamesGameId(ctx.Request().Context(), request.(GetGamesGameIdRequestObject)) + } + for _, middleware := range sh.middlewares { + handler = middleware(handler, "GetGamesGameId") + } + + response, err := handler(ctx, request) + + if err != nil { + return err + } else if validResponse, ok := response.(GetGamesGameIdResponseObject); ok { + return validResponse.VisitGetGamesGameIdResponse(ctx.Response()) + } else if response != nil { + return fmt.Errorf("unexpected response type: %T", response) + } + return nil +} + // PostLogin operation middleware func (sh *strictHandler) PostLogin(ctx echo.Context) error { var request PostLoginRequestObject @@ -542,23 +647,24 @@ func (sh *strictHandler) PostLogin(ctx echo.Context) error { // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/6xWW2+jRhT+K2jaR+RrFG15S9N2ldVWter2aRVZx3BsJoWZ2TlDsu6K/76aGQzG4Bgn", - "zkNC4Fy+853rdxbLXEmBwhCLvjOKU8zBPX6EHO1fpaVCbTi6twknlcFuJaqv+A1ylSGLnHwwZSEzO2X/", - "J6O52LIyZEmhwXApVoSxFAm19Oa3k1qFC4Nb1FZnCzmueNISnfYJKi3XGeZW8GeNGxaxn8ZNTOMqoPGi", - "EitDRga0wWQFpmX9l5vb2w83Hya9cMiA8fGKImfRFxZnkjBhIXsBbrjYrlAYbTlq3jg/zCJEBRpZ5dmS", - "4uLzDxsuOKWYsMfwgEyIDX/GLpllyDR+LbjGxKLYs7QHGLbz00P9Y21Srp8wNjY4m7lFBjvUfyIRbF2g", - "UuBfGxZ9eZ3Wjupyds/K8EKl+9mSlY99SOyXt4O5ny1/F0bv3oTob4RkdxqWN9zpD0+ubStBhkVMObUo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zChv3G9nQQPSsTHdCNG8vppdDg+Wds7Ieic3RwwR21Vid9Sq06h/cm6hf3b/R", + "zu/xLc4HOaX68zJNkWhV5vkmgtJmKK2DijzI+eLccr6XT5ALHqUGuTsLcjqrnLfxt9WMlImacnYV/jeh", + "iYKsq6qq/gsAAP//bqjkD+ERAAA=", } // GetSwagger returns the content of the embedded swagger specification file |
