agoravaisedeusquiser
This commit is contained in:
12
app/main.py
12
app/main.py
@@ -1,6 +1,7 @@
|
||||
from fastapi import FastAPI, Depends
|
||||
from fastapi import FastAPI, Depends, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from app.core.security import get_current_user, UserAuth
|
||||
from fastapi.responses import JSONResponse
|
||||
from app.core.security import get_current_user, UserAuth, AuthException
|
||||
from app.core.config import settings
|
||||
from app.api.v1.api import api_router
|
||||
from app.db.database import Base, engine
|
||||
@@ -23,6 +24,13 @@ app.add_middleware(
|
||||
|
||||
app.include_router(api_router, prefix=settings.API_V1_STR)
|
||||
|
||||
@app.exception_handler(AuthException)
|
||||
async def auth_exception_handler(request: Request, exc: AuthException):
|
||||
return JSONResponse(
|
||||
status_code=401,
|
||||
content={"message": exc.message}
|
||||
)
|
||||
|
||||
@app.get("/")
|
||||
def root(current_user: UserAuth = Depends(get_current_user)):
|
||||
return {"message": "Bem-vindo ao Microsserviço de Catálogo do GameVerse"}
|
||||
|
||||
Reference in New Issue
Block a user