File tree Expand file tree Collapse file tree
a2a/weather_service/src/weather_service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -215,14 +215,16 @@ def run():
215215 # Add tracing middleware - creates root span with MLflow/GenAI attributes
216216 app .add_middleware (BaseHTTPMiddleware , dispatch = create_tracing_middleware ())
217217
218+ class LogAuthorizationMiddleware (BaseHTTPMiddleware ):
219+ async def dispatch (self , request , call_next ):
220+ auth_header = request .headers .get ("authorization" , "No Authorization header" )
221+ logger .info (
222+ f"🔐 Incoming request to { request .url .path } with Authorization: { auth_header [:80 ] + '...' if len (auth_header ) > 80 else auth_header } "
223+ )
224+ response = await call_next (request )
225+ return response
226+
218227 # Add logging middleware
219- @app .middleware ("http" )
220- async def log_authorization_header (request , call_next ):
221- auth_header = request .headers .get ("authorization" , "No Authorization header" )
222- logger .info (
223- f"🔐 Incoming request to { request .url .path } with Authorization: { auth_header [:80 ] + '...' if len (auth_header ) > 80 else auth_header } "
224- )
225- response = await call_next (request )
226- return response
228+ app .add_middleware (LogAuthorizationMiddleware )
227229
228230 uvicorn .run (app , host = "0.0.0.0" , port = 8000 )
You can’t perform that action at this time.
0 commit comments