diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-28 16:19:52 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-28 17:12:12 +0900 |
| commit | 0dd94cbea6e857896c46d17493725f97369d99f9 (patch) | |
| tree | 8d324c16eecfb3fb510488c9339e9c4c4a0692ce /backend/api/handlers.go | |
| parent | d24c19963f8d0d17d6db93b418cc9d644693c868 (diff) | |
| download | iosdc-japan-2025-albatross-0dd94cbea6e857896c46d17493725f97369d99f9.tar.gz iosdc-japan-2025-albatross-0dd94cbea6e857896c46d17493725f97369d99f9.tar.zst iosdc-japan-2025-albatross-0dd94cbea6e857896c46d17493725f97369d99f9.zip | |
refactor: remove /api/ prefix from openapi.yaml
Diffstat (limited to 'backend/api/handlers.go')
| -rw-r--r-- | backend/api/handlers.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/backend/api/handlers.go b/backend/api/handlers.go index ee0a97a..162e30a 100644 --- a/backend/api/handlers.go +++ b/backend/api/handlers.go @@ -21,19 +21,19 @@ func NewHandler(queries *db.Queries) *ApiHandler { } } -func (h *ApiHandler) PostApiLogin(ctx context.Context, request PostApiLoginRequestObject) (PostApiLoginResponseObject, error) { +func (h *ApiHandler) 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) if err != nil { - return PostApiLogin401JSONResponse{ + return PostLogin401JSONResponse{ Message: "Invalid username or password", }, echo.NewHTTPError(http.StatusUnauthorized, "Invalid username or password") } user, err := h.q.GetUserById(ctx, int32(userId)) if err != nil { - return PostApiLogin401JSONResponse{ + return PostLogin401JSONResponse{ Message: "Invalid username or password", }, echo.NewHTTPError(http.StatusUnauthorized, "Invalid username or password") } @@ -41,12 +41,12 @@ func (h *ApiHandler) PostApiLogin(ctx context.Context, request PostApiLoginReque jwt, err := auth.NewJWT(&user) if err != nil { // TODO - return PostApiLogin401JSONResponse{ + return PostLogin401JSONResponse{ Message: "Internal Server Error", }, echo.NewHTTPError(http.StatusInternalServerError, "Internal Server Error") } - return PostApiLogin200JSONResponse{ + return PostLogin200JSONResponse{ Token: jwt, }, nil } @@ -64,7 +64,7 @@ func _assertJwtPayloadIsCompatibleWithJWTClaims() { func NewJWTMiddleware() StrictMiddlewareFunc { return func(handler StrictHandlerFunc, operationID string) StrictHandlerFunc { - if operationID == "PostApiLogin" { + if operationID == "PostLogin" { return handler } else { return func(c echo.Context, request interface{}) (response interface{}, err error) { |
