File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
webapp/packages/api/user-service Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change 1515import httpx
1616import yaml
1717from fastapi .security import OAuth2PasswordBearer
18+ from contextlib import asynccontextmanager
1819
1920from services .database_service import get_database_service , DatabaseService
2021from config import settings
4445from agent_factory .remote_mcp_client import RemoteMCPClient
4546
4647
47- app = FastAPI ()
48- router = APIRouter ()
49-
50- # Add observability middleware
51- app .add_middleware (ObservabilityMiddleware )
52-
53- @app .on_event ("startup" )
54- async def startup_event ():
55- """Log application startup event."""
48+ @asynccontextmanager
49+ async def lifespan (app : FastAPI ):
50+ """Application lifespan handler."""
5651 logger = get_observability_service ()
5752 logger .log (
5853 level = "INFO" ,
5954 event_type = "lifecycle" ,
6055 message = "Application startup complete."
6156 )
57+ yield
6258
6359
60+ app = FastAPI (lifespan = lifespan )
61+ router = APIRouter ()
62+
63+ # Add observability middleware
64+ app .add_middleware (ObservabilityMiddleware )
65+
6466oauth2_scheme = OAuth2PasswordBearer (tokenUrl = "token" , auto_error = False )
6567
6668
You can’t perform that action at this time.
0 commit comments