Adds Exception Handlers
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from starlette.responses import JSONResponse
|
||||
|
||||
from storage_service.config.config_allowed_origins import get_allowed_origins
|
||||
from storage_service.controller.health_checker_controller import health_router
|
||||
from storage_service.controller.storage_controller import s3_router
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, HTTPException
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from storage_service.utils.exception_handler import http_exception_handler, validation_exception_handler
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
app.add_exception_handler(HTTPException, http_exception_handler)
|
||||
app.add_exception_handler(RequestValidationError, validation_exception_handler)
|
||||
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=get_allowed_origins(),
|
||||
|
||||
Reference in New Issue
Block a user