No project description provided
Project description
asgi_etags
Simple etags middleware for asgi apps.
Installation
The library is available on PyPI:
pip install asgi_etags
Or in the Releases
tab, both in sdist
format as well as wheels
.
Example usage:
With FastAPI
from fastapi import FastAPI
from hashlib import md5
from asgi_etags import ETagMiddlewareFactory
app = FastAPI()
app.add_middleware(ETagMiddlewareFactory(lambda body: md5(body).hexdigest()))
@app.get("/")
def hello_world():
return {"hello": "world"}
With Litestar
from litestar import Litestar
@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=[ETagMiddlewareFactory(lambda body: md5(body).hexdigest())],
)
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
asgi_etags-0.1.0.tar.gz
(4.0 kB
view hashes)
Built Distributions
Close
Hashes for asgi_etags-0.1.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3259a74c557d4a625df35ed244d413a5504dd8538f9f580c55c19d624e70dcf |
|
MD5 | b4f544c48c84ef23dc634b9ceaf237f8 |
|
BLAKE2b-256 | 8256b5a0d7cbd6090e687e5cfdc9d0fd376b4f19f1837cae5be0267d8449bbdc |
Close
Hashes for asgi_etags-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bf4dfc76da9b61abec8993dacd8bf196200a66a5edc56bfecc672daef115dc0 |
|
MD5 | 0363759f8dee08fbecfc3d3e85c4862a |
|
BLAKE2b-256 | a4af2a3995079a71134de630fa5073dd70c01e3dbd48bc07dcaf1e843733562a |
Close
Hashes for asgi_etags-0.1.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a204d923b46c7dd209877ea1b850a7e61d89af64a555af16ad65bfa38e122714 |
|
MD5 | b52c264a9bf1a017f992b9b02ca9db76 |
|
BLAKE2b-256 | 5880401c967347c78795162d2557cc0b2ec6b8bffc0e65797cb43d80aa70e6e0 |