From b0638f195a30fc58018fd857e6729cea6e9f30d9 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Wed, 25 Oct 2023 13:34:47 -0300 Subject: [PATCH] Fix more bugs --- gateway/src/api/config.py | 6 +++--- gateway/src/api/routes/auth.py | 8 ++++---- gateway/src/api/routes/flights.py | 6 +++--- gateway/src/api/routes/users.py | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/src/api/config.py b/gateway/src/api/config.py index 2d923ad..1f68bc3 100644 --- a/gateway/src/api/config.py +++ b/gateway/src/api/config.py @@ -1,3 +1,3 @@ -API_USERS = "http://fids_usermanager_api:5000/users/" -API_FLIGHTS = "http://fids_flights_api:5000/flights/" -API_AUTH = "http://fids_usermanager_api:5000/auth/" +API_USERS = "http://fids_usermanager_api:5000/users" +API_FLIGHTS = "http://fids_flights_api:5000/flights" +API_AUTH = "http://fids_usermanager_api:5000/auth" diff --git a/gateway/src/api/routes/auth.py b/gateway/src/api/routes/auth.py index 035a381..3ab09cf 100644 --- a/gateway/src/api/routes/auth.py +++ b/gateway/src/api/routes/auth.py @@ -13,7 +13,7 @@ router = APIRouter() @router.post("/register", response_model=UserMin) async def register(user: UserRegister): (response, status, _) = await request( - f"{API_AUTH}register", "POST", json=user.model_dump() + f"{API_AUTH}/register", "POST", json=user.model_dump() ) if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) @@ -23,7 +23,7 @@ async def register(user: UserRegister): @router.post("/login", response_model=Token) async def login(user: UserLogin): (response, status, _) = await request( - f"{API_AUTH}login", "POST", json=user.model_dump() + f"{API_AUTH}/login", "POST", json=user.model_dump() ) if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) @@ -33,7 +33,7 @@ async def login(user: UserLogin): @router.post("/refresh", response_model=Token) async def refresh(token: RefreshToken): (response, status, _) = await request( - f"{API_AUTH}refresh", "POST", json=token.model_dump() + f"{API_AUTH}/refresh", "POST", json=token.model_dump() ) if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) @@ -43,7 +43,7 @@ async def refresh(token: RefreshToken): @router.get("/status", response_model=UserMin) async def status(authorization: Annotated[str | None, Header()] = None): header = {"Authorization": authorization if authorization is not None else ""} - (response, status, _) = await request(f"{API_AUTH}status", "GET", headers=header) + (response, status, _) = await request(f"{API_AUTH}/status", "GET", headers=header) if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) return response diff --git a/gateway/src/api/routes/flights.py b/gateway/src/api/routes/flights.py index be8ff67..85d1fb4 100644 --- a/gateway/src/api/routes/flights.py +++ b/gateway/src/api/routes/flights.py @@ -12,7 +12,7 @@ router = APIRouter() @router.get("/{id}", response_model=Flight) async def get_flight_by_id(id: int): - (response, status, _) = await request(f"{API_FLIGHTS}{id}", "GET") + (response, status, _) = await request(f"{API_FLIGHTS}/{id}", "GET") if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) return response @@ -39,7 +39,7 @@ async def update_flight( ): await checkAuth(authorization) (response, status, _) = await request( - f"{API_FLIGHTS}{id}", "PATCH", json=status_update.model_dump() + f"{API_FLIGHTS}/{id}", "PATCH", json=status_update.model_dump() ) if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) @@ -53,7 +53,7 @@ async def get_flights(origin: Optional[str] = None, lastUpdated: Optional[str] = query["origin"] = origin if lastUpdated: query["lastUpdated"] = lastUpdated - (response, status, _) = await request(f"{API_FLIGHTS}", "GET", query=lastUpdated) + (response, status, _) = await request(f"{API_FLIGHTS}", "GET", query=query) if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) return response diff --git a/gateway/src/api/routes/users.py b/gateway/src/api/routes/users.py index 17bcf9e..0313cb1 100644 --- a/gateway/src/api/routes/users.py +++ b/gateway/src/api/routes/users.py @@ -27,7 +27,7 @@ async def create_users(user: UserRegister): @router.get("/{id}", response_model=User) async def get_user(id: str): - (response, status, _) = await request(f"{API_USERS}{id}", "GET") + (response, status, _) = await request(f"{API_USERS}/{id}", "GET") if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) return response @@ -36,7 +36,7 @@ async def get_user(id: str): @router.put("/{id}", response_model=User) async def update_user(user: UserRegister): (response, status, _) = await request( - f"{API_USERS}{id}", "PUT", json=user.model_dump() + f"{API_USERS}/{id}", "PUT", json=user.model_dump() ) if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) @@ -45,7 +45,7 @@ async def update_user(user: UserRegister): @router.delete("/{id}", response_model=User) async def delete_user(): - (response, status, _) = await request(f"{API_USERS}{id}", "DELETE") + (response, status, _) = await request(f"{API_USERS}/{id}", "DELETE") if status < 200 or status > 204: raise HTTPException(status_code=status, detail=response) return response