No project description provided
Project description
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")
}
),
]
)
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 Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asgi_headers-0.1.1.tar.gz.
File metadata
- Download URL: asgi_headers-0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef6ec8cf9fa911bd9cf9204303ad7aa935d34cab5d7ddf4d9376e1af75418def
|
|
| MD5 |
d8617367045d4cdf18ee00e77c6af949
|
|
| BLAKE2b-256 |
90546fae53ef40a3ddb9d2949542384ac02e4e9665f9e7de8c5c74de86da75b5
|
File details
Details for the file asgi_headers-0.1.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: asgi_headers-0.1.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 55.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
448bcf194b24b43a87a4457ff19242b518d0a1d28057d9b3959075d6d83f9432
|
|
| MD5 |
261b1f90d6fca8f1575804d7da68a4e5
|
|
| BLAKE2b-256 |
cfbe6a611c30a5e7d98071862bd861fddf67fb81b22f21fd8ba6b5d48417f659
|
File details
Details for the file asgi_headers-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: asgi_headers-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 148.0 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f4d0584a2a6e3e67ee0b098a025e3b3aee519e44abec0e0426fd5bc8a16a0a3
|
|
| MD5 |
7c5ccf431b7ea19c9f92078418093798
|
|
| BLAKE2b-256 |
2772989e1820d125a14261c2c5c0b91e00e7fb458194f5c1c7de896a5f1e2ef3
|
File details
Details for the file asgi_headers-0.1.1-cp312-cp312-macosx_10_9_universal2.whl.
File metadata
- Download URL: asgi_headers-0.1.1-cp312-cp312-macosx_10_9_universal2.whl
- Upload date:
- Size: 148.4 kB
- Tags: CPython 3.12, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0468078d62e1d1ece9d07005d77e8c8045265f5a8f9a064a548e12ea40695d37
|
|
| MD5 |
ec5085b4e38df1a0544a85f663e2167c
|
|
| BLAKE2b-256 |
6d46417ef8be064670d8b9bf7d27ba256ae15dbcbad0f1bd912de0fa19b299c8
|
File details
Details for the file asgi_headers-0.1.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: asgi_headers-0.1.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 55.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0bccbcd9a93ea22cc44078a92697fef173f25f125ac1b1eef2e85f3d9223666
|
|
| MD5 |
2ea31a6be09663c84e75612089a96325
|
|
| BLAKE2b-256 |
1a7811d90c59865aabb551b9a8f94d8a97e95cfb52285b17c51fd71d9b50fb9c
|
File details
Details for the file asgi_headers-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: asgi_headers-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 142.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c159ad9ee7f06d6f508fa9d428c6676e0084338a1a61e71201350f3796173b2
|
|
| MD5 |
e9aaca3f9155091ccd2991531a885c29
|
|
| BLAKE2b-256 |
165a635028df397dc6769cfbad21eb19a50ce287345f2aeeabd8a24f96b2b756
|
File details
Details for the file asgi_headers-0.1.1-cp311-cp311-macosx_10_9_universal2.whl.
File metadata
- Download URL: asgi_headers-0.1.1-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 145.1 kB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.10.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e398d293634a324715fa3a54572ddd18ce3a210ed4386f9f936154cc3066dcf
|
|
| MD5 |
50baef64836cf7f2047a773b56ffd6a2
|
|
| BLAKE2b-256 |
407157270ed264d0936676f8df894754c5c9a53cf1735e19dd59a38f6cd9ee7e
|