Created
February 19, 2021 17:28
-
-
Save Montgoner/bb2fd5e98eb807829d9601581471cab6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LATEST_API_VERSION = APIVersion(major_version=1, minor_version=1) | |
# Create app object and add routes | |
app = FastAPI(title="My Item App") | |
app.include_router(unversioned_router) | |
app.include_router(router_v1_0) | |
app.include_router(router_v1_1) | |
exception_handlers = { | |
500: internal_error_exception_handler, # Uncontrolled internal server errors (e.g. raised by FastAPI's middlewares) | |
CustomServiceError: internal_error_exception_handler, # Controlled internal server errors | |
RequestValidationError: request_validation_exception_handler, # Custom data validation error | |
} | |
app = version_app(app, default_api_version=LATEST_API_VERSION, exception_handlers=exception_handlers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment