Middleware propagating headers from incoming requests to outgoing requests in fastapi
Project description
Header Propagation Middleware
Middleware for propagating headers from incoming requests to outgoing requests for FastAPI.
Installation
pip install header-propagation-middleware
Setup
To setup the middleware, you need to add it to your FastAPI app.
Adding Middleware
from header_propagation_middleware import HeaderPropagationMiddleware
app = FastAPI()
app.add_middleware(HeaderPropagationMiddleware,header_names=["header1","header2"])
Configurable middleware argument
header_names
- Type:
List[str]
- Default:
[]
- Description: The list of headers to propagate.
Accessing propagated headers
You can access the propagated headers using the propagated_headers
object.
from header_propagation_middleware import propagated_headers
propagated_headers.get()
propagated_headers
- Type:
dict
- Default:
{}
- Description: The dictionary of propagated headers.
Tests
Running test
python -m pytest
Running test with coverage report
python -m pytest --cov --cov-report=html:reports/html_dir
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
File details
Details for the file header_propagation-1.0.0.tar.gz
.
File metadata
- Download URL: header_propagation-1.0.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f6c7d150391660ca4c1c6cb871e9ec6b4adca6aaab77f22580d233aacede2b8 |
|
MD5 | 1d486c812db46f15d7cb0aeeab5ae335 |
|
BLAKE2b-256 | 95dd37c25549106e3d9373f1e4d19c197bd3619173f6e33d25847791b6523caa |
File details
Details for the file header_propagation-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: header_propagation-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfa901061ec5aa822d6d78175b0c3e905fd9e615cafdc2f50b68df29f6789811 |
|
MD5 | 43311e2b78bf3b62cae0c177799c9f10 |
|
BLAKE2b-256 | 340f910402e33454ae1ae4100c63dedc7efa77e3682988ab315d8848d26fcf1f |