Ligare.web.middleware.context
Functions
|
Extract the mime type and encoding from the content type headers. |
|
Split the content type in mime_type and encoding. |
Classes
Generate a Correlation ID for each request. |
|
|
Generate a Trace ID for each request. |
|
- class Ligare.web.middleware.context.CorrelationIdMiddleware(app)[source]
Generate a Correlation ID for each request.
- class Ligare.web.middleware.context.MiddlewareRequestDict
-
app:
ConnexionMiddleware
-
client:
list[str|int]
-
extensions:
dict[str,dict[str,str]]
-
headers:
list[tuple[bytes,bytes]]
-
http_version:
str
-
method:
Literal['GET','POST','PATCH','PUT','DELETE','OPTIONS','HEAD','CONNECT','TRACE']
-
path:
str
-
path_params:
dict[Any,Any]
-
query_string:
bytes
-
raw_path:
bytes
-
root_path:
str
-
scheme:
str
-
server:
list[str|int]
-
state:
dict[Any,Union[Any,dict[Any,Union[Any, AnyDict]]]]
-
type:
Literal['http']
-
app:
- class Ligare.web.middleware.context.MiddlewareResponseDict
-
headers:
list[tuple[bytes,bytes]]
-
status:
int
-
type:
Literal['http.response.start']
-
headers:
- class Ligare.web.middleware.context.RequestIdMiddleware(app)[source]
Generate a Trace ID for each request. If X-Correlation-Id is set in the request headers, that ID is used instead.
- class Ligare.web.middleware.context.TraceId(CorrelationId, RequestId)[source]
-
CorrelationId:
Optional[NewType(CorrelationId,str)] Alias for field number 0
-
RequestId:
Optional[NewType(RequestId,str)] Alias for field number 1
-
CorrelationId:
- Ligare.web.middleware.context.extract_content_type(headers)[source]
Extract the mime type and encoding from the content type headers.
- Parameters:
headers (
list[tuple[bytes,bytes]] |dict[str,str]) – Headers from ASGI scope- Return type:
str|None- Returns:
The content type if available in headers, otherwise None