Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

header_propagation-1.0.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

header_propagation-1.0.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

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

Hashes for header_propagation-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2f6c7d150391660ca4c1c6cb871e9ec6b4adca6aaab77f22580d233aacede2b8
MD5 1d486c812db46f15d7cb0aeeab5ae335
BLAKE2b-256 95dd37c25549106e3d9373f1e4d19c197bd3619173f6e33d25847791b6523caa

See more details on using hashes here.

File details

Details for the file header_propagation-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for header_propagation-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfa901061ec5aa822d6d78175b0c3e905fd9e615cafdc2f50b68df29f6789811
MD5 43311e2b78bf3b62cae0c177799c9f10
BLAKE2b-256 340f910402e33454ae1ae4100c63dedc7efa77e3682988ab315d8848d26fcf1f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page