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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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