Platform bundle: marketing publish, IT ops, packaging, agents mesh.
Volledige Foodlinkk Command Center uitbreiding met social automatisering, reclamefolder filters, Proxmox monitoring en documentatie.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""Log Tools API mutations to agent_events."""
|
||||
from __future__ import annotations
|
||||
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from starlette.requests import Request
|
||||
|
||||
from app.middleware import log_agent_event
|
||||
|
||||
|
||||
class AgentLoggingMiddleware(BaseHTTPMiddleware):
|
||||
async def dispatch(self, request: Request, call_next):
|
||||
response = await call_next(request)
|
||||
if request.method in ("POST", "PUT", "PATCH", "DELETE") and response.status_code < 400:
|
||||
path = request.url.path
|
||||
if path.startswith(("/research", "/recommendations", "/retail", "/events")):
|
||||
try:
|
||||
log_agent_event(
|
||||
agent_name="tools_api",
|
||||
event_type="api_call",
|
||||
title=f"{request.method} {path}",
|
||||
channel="api",
|
||||
metadata={"status": response.status_code},
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
return response
|
||||
Reference in New Issue
Block a user