Skip to main content

asgi_headers

Simple middleware for injecting headers in ASGI apps.

Installation

The library is available on PyPI:

pip install asgi_headers

Or in the Releases tab, both in sdist format as well as wheels.

Supported Python versions

Currently the library supports Python 3.11 only.

Example usage:

With FastAPI

from fastapi import FastAPI
from asgi_headers import InjectHeadersMiddleware

app = FastAPI()
app.add_middleware(
    InjectHeadersMiddleware,
    injections={
        ("GET", "/hello"): {"This-Header-Will-Be-Injected-To-All-GET-Requests-Starting-With-/foo-path": 1},
        ("*", "/hello", "This-Header-Will-Be-Injected-To-All-Requests-Starting-With-/foo-path", "1")
        ("GET", "*", "This-Header-Will-Be-Injected-To-All-GET-Requests", "1")
        ("*", "*", "This-Header-Will-Be-Injected-To-All-Requests", "1")
    }
)

@app.get("/hello")
def hello_world():
    return {"hello": "world"}

With Litestar

from litestar import Litestar
from asgi_headers import InjectHeadersMiddlewareFactory

@get(path="/", media_type="application/json", sync_to_thread=False)
def hello_world() -> dict[str, str]:
    return {"hello": "world"}

app = Litestar(
    route_handlers=[hello_world],
    middleware=[
        InjectHeadersMiddlewareFactory(
            injections={
                ("GET", "/hello"): {"This-Header-Will-Be-Injected-To-All-GET-Requests-Starting-With-/foo-path": 1},
                ("*", "/hello", "This-Header-Will-Be-Injected-To-All-Requests-Starting-With-/foo-path", "1")
                ("GET", "*", "This-Header-Will-Be-Injected-To-All-GET-Requests", "1")
                ("*", "*", "This-Header-Will-Be-Injected-To-All-Requests", "1")
            }
        ),
    ]
)

Metadata

Release files for asgi_headers 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asgi_headers 0.1.1
File Size Uploaded Provenance Actions
asgi_headers-0.1.1.tar.gz 4.6 kB Without provenance Details for asgi_headers-0.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for asgi_headers 0.1.1
File Actions
asgi_headers-0.1.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for asgi_headers-0.1.1-cp312-cp312-win_amd64.whl
asgi_headers-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details for asgi_headers-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
asgi_headers-0.1.1-cp312-cp312-macosx_10_9_universal2.whl CPython 3.12 CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64) Details for asgi_headers-0.1.1-cp312-cp312-macosx_10_9_universal2.whl
asgi_headers-0.1.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for asgi_headers-0.1.1-cp311-cp311-win_amd64.whl
asgi_headers-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details for asgi_headers-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
asgi_headers-0.1.1-cp311-cp311-macosx_10_9_universal2.whl CPython 3.11 CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) Details for asgi_headers-0.1.1-cp311-cp311-macosx_10_9_universal2.whl

Total release size: 698.5 kB

Release files / asgi_headers-0.1.1.tar.gz

Download URL asgi_headers-0.1.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ef6ec8cf9fa911bd9cf9204303ad7aa935d34cab5d7ddf4d9376e1af75418def
BLAKE2b-256 checksum
How to use checksums
90546fae53ef40a3ddb9d2949542384ac02e4e9665f9e7de8c5c74de86da75b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.10.0 CPython/3.10.12

Release files / asgi_headers-0.1.1-cp312-cp312-win_amd64.whl

Download URL asgi_headers-0.1.1-cp312-cp312-win_amd64.whl
Size 55.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
448bcf194b24b43a87a4457ff19242b518d0a1d28057d9b3959075d6d83f9432
BLAKE2b-256 checksum
How to use checksums
cfbe6a611c30a5e7d98071862bd861fddf67fb81b22f21fd8ba6b5d48417f659
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.10.0 CPython/3.10.12

Release files / asgi_headers-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL asgi_headers-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 148.0 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7f4d0584a2a6e3e67ee0b098a025e3b3aee519e44abec0e0426fd5bc8a16a0a3
BLAKE2b-256 checksum
How to use checksums
2772989e1820d125a14261c2c5c0b91e00e7fb458194f5c1c7de896a5f1e2ef3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.10.0 CPython/3.10.12

Release files / asgi_headers-0.1.1-cp312-cp312-macosx_10_9_universal2.whl

Download URL asgi_headers-0.1.1-cp312-cp312-macosx_10_9_universal2.whl
Size 148.4 kB
Tags CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
0468078d62e1d1ece9d07005d77e8c8045265f5a8f9a064a548e12ea40695d37
BLAKE2b-256 checksum
How to use checksums
6d46417ef8be064670d8b9bf7d27ba256ae15dbcbad0f1bd912de0fa19b299c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.10.0 CPython/3.10.12

Release files / asgi_headers-0.1.1-cp311-cp311-win_amd64.whl

Download URL asgi_headers-0.1.1-cp311-cp311-win_amd64.whl
Size 55.0 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
e0bccbcd9a93ea22cc44078a92697fef173f25f125ac1b1eef2e85f3d9223666
BLAKE2b-256 checksum
How to use checksums
1a7811d90c59865aabb551b9a8f94d8a97e95cfb52285b17c51fd71d9b50fb9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.10.0 CPython/3.10.12

Release files / asgi_headers-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl

Download URL asgi_headers-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Size 142.1 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8c159ad9ee7f06d6f508fa9d428c6676e0084338a1a61e71201350f3796173b2
BLAKE2b-256 checksum
How to use checksums
165a635028df397dc6769cfbad21eb19a50ce287345f2aeeabd8a24f96b2b756
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.10.0 CPython/3.10.12

Release files / asgi_headers-0.1.1-cp311-cp311-macosx_10_9_universal2.whl

Download URL asgi_headers-0.1.1-cp311-cp311-macosx_10_9_universal2.whl
Size 145.1 kB
Tags CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
6e398d293634a324715fa3a54572ddd18ce3a210ed4386f9f936154cc3066dcf
BLAKE2b-256 checksum
How to use checksums
407157270ed264d0936676f8df894754c5c9a53cf1735e19dd59a38f6cd9ee7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.10.0 CPython/3.10.12

Security for asgi_headers 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

7 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page