Version 0.4.0
All checks were successful
Run linters on applied template / Python 3.13 lint and build (push) Successful in 1m40s
All checks were successful
Run linters on applied template / Python 3.13 lint and build (push) Successful in 1m40s
Changes: - put ObservabilityMiddleware before ExceptionHandlerMiddleware to avoid repetative code - add application startup and last metrics update metrics along with CPU usage metric and threads count - move host and port to new uvicorn section at config along with new reload and forwarded_allow_ips - add request_id and remove trace_id/span_id generation if tracing is disabled - move logging logic from utils to observability - pass trace_id/span_id in HEX form
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import fastapi
|
||||
from starlette import status
|
||||
|
||||
from {{project_slug}}.db.connection.manager import PostgresConnectionManager
|
||||
from {{project_slug}}.dependencies import connection_manager_dep
|
||||
from {{project_slug}}.logic import system as system_logic
|
||||
from {{project_slug}}.schemas import PingResponse
|
||||
@@ -11,9 +12,9 @@ from .routers import system_router
|
||||
|
||||
|
||||
@system_router.get("/", status_code=status.HTTP_307_TEMPORARY_REDIRECT, include_in_schema=False)
|
||||
@system_router.get("/api/", status_code=status.HTTP_307_TEMPORARY_REDIRECT, include_in_schema=False)
|
||||
@system_router.get("/api", status_code=status.HTTP_307_TEMPORARY_REDIRECT, include_in_schema=False)
|
||||
async def redirect_to_swagger_docs():
|
||||
"""Redirects to **/api/docs** from **/**"""
|
||||
"""Redirects to **/api/docs** from **/** and **/api**."""
|
||||
return fastapi.responses.RedirectResponse("/api/docs", status_code=status.HTTP_307_TEMPORARY_REDIRECT)
|
||||
|
||||
|
||||
@@ -34,10 +35,10 @@ async def ping():
|
||||
response_model=PingResponse,
|
||||
status_code=status.HTTP_200_OK,
|
||||
)
|
||||
async def ping_db(request: fastapi.Request, readonly: bool = False):
|
||||
"""
|
||||
Check that database connection is valid.
|
||||
"""
|
||||
connection_manager = connection_manager_dep.obtain(request)
|
||||
async def ping_db(
|
||||
readonly: bool = False,
|
||||
connection_manager: PostgresConnectionManager = fastapi.Depends(connection_manager_dep.from_request),
|
||||
):
|
||||
"""Check that database connection is valid."""
|
||||
|
||||
return await system_logic.ping_db(connection_manager, readonly)
|
||||
|
||||
Reference in New Issue
Block a user