Работает агент, поправлены пути
This commit is contained in:
@@ -2,6 +2,7 @@ import logging
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from starlette.requests import Request
|
||||
|
||||
from app.infra.logging_setup import configure_logging
|
||||
from app.infra.error_handlers import register_error_handlers
|
||||
@@ -19,6 +20,7 @@ def create_app() -> FastAPI:
|
||||
app = FastAPI(title="Agent Backend MVP", version="0.1.0")
|
||||
modules = ModularApplication()
|
||||
app.state.modules = modules
|
||||
logger = logging.getLogger("app.http")
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
@@ -30,6 +32,22 @@ def create_app() -> FastAPI:
|
||||
app.include_router(modules.api.public_router())
|
||||
register_error_handlers(app)
|
||||
|
||||
@app.middleware("http")
|
||||
async def log_http_requests(request: Request, call_next):
|
||||
logger.warning("http request: method=%s path=%s query=%s", request.method, request.url.path, request.url.query)
|
||||
try:
|
||||
response = await call_next(request)
|
||||
logger.warning(
|
||||
"http response: method=%s path=%s status=%s",
|
||||
request.method,
|
||||
request.url.path,
|
||||
response.status_code,
|
||||
)
|
||||
return response
|
||||
except Exception:
|
||||
logger.exception("http request failed: method=%s path=%s", request.method, request.url.path)
|
||||
raise
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup() -> None:
|
||||
modules.startup()
|
||||
|
||||
Reference in New Issue
Block a user