Receive and return the value of HTTP X-Request-ID header.
Project description
request-id-flask
Attach a unique identifier to every HTTP request in your WSGI application.
request-id-flask
is implemented as a WSGI middleware.
The package will do one of two things:
-
Read the
X-Request-ID
HTTP header from a client HTTP request and return the sameX-Request-ID
HTTP header in the server HTTP response and is stored in the WSGIenviron
. -
Or, when no
X-Request-ID
HTTP header is present in the client HTTP request, generate a new and uniquerequest_id
identifier (using uuid 4) which is stored in the WSGIenviron
and set as theX-Request-ID
HTTP header in the server HTTP responser.
Requirements
- Python 3.6 or above
Installation
You can install the request-id-flask package using pip:
pip install flask-ext-request-id
However, recommended to add it to the requirements.txt
file instead.
Access the request_id
The REQUEST_ID
is stored in the request environ
dictionary and may be accessed from anywhere this is available in Flask.
Usage
from flask import Flask
from request_id import RequestId
app = Flask(__name__)
RequestId(app)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for request_id_flask-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb92cdfe3b1728664ae84e4e4afc2a79b9fa28c5c45fc4a16b0c5ba82d175e76 |
|
MD5 | 8a53394b8a100da4980180c9eabc6bb5 |
|
BLAKE2b-256 | 9cf7a558aa03eca5e4f1edfe7e28c43d2aeb4781333c49e2bc681f8df2bb63b1 |