We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 25125e0 commit 03709a5Copy full SHA for 03709a5
1 file changed
fastapi_structlog/middleware/utils.py
@@ -75,11 +75,11 @@ def find_api_source(
75
_: Optional[dict[str, Any]] = None,
76
) -> Optional[dict[str, Any]]:
77
"""Find location of endpoint."""
78
- if 'endpoint' in scope:
+ if 'endpoint' in scope and hasattr(scope['endpoint'], '__globals__'):
79
return {
80
- 'package': scope['endpoint'].__globals__['__package__'],
81
- 'file': scope['endpoint'].__globals__['__file__'],
82
- 'function': scope['endpoint'].__name__,
+ 'package': scope['endpoint'].__globals__.get('__package__'),
+ 'file': scope['endpoint'].__globals__.get('__file__'),
+ 'function': getattr(scope['endpoint'], '__name__', None),
83
}
84
return None
85
0 commit comments