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
.
Supported Python versions
Currently the library supports Python 3.11 only.
Example usage:
With FastAPI
from fastapi import FastAPI
from hashlib import md5
from asgi_etags import ETagMiddleware
app = FastAPI()
app.add_middleware(ETagMiddleware, etag_generator=lambda body: md5(body).hexdigest())
@app.get("/")
def hello_world():
return {"hello": "world"}
With Litestar
from litestar import Litestar
from hashlib import md5
from asgi_etags import ETagMiddlewareFactory
@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.1.tar.gz
(4.0 kB
view hashes)
Built Distributions
Close
Hashes for asgi_etags-0.1.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e92c87c3ee57bfe59e1abe09b21204d2cfb626bcba575b5ff1ea12e7f02dc582 |
|
MD5 | ebe9d47c7dfc11562542afeac556ff91 |
|
BLAKE2b-256 | 77ab0927c87e974b4b6c950aeb824d4ef9db8ca46d724026d7ad05dc92b37951 |
Close
Hashes for asgi_etags-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d00a8cfdaa3fbe1755fb3141cec3c485491be1d51a5e4f818d6722723513e249 |
|
MD5 | b83ea0d596f7191cc6d19c8aa1b5ef38 |
|
BLAKE2b-256 | e6c02478cb62c00443101d6b8ea023b0e801fc4f5b5737f6d0320b1cfe9faefa |
Close
Hashes for asgi_etags-0.1.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4978e577c11f4e4a53ce0e227f9352a5931e107b815d607e9176bc909540a020 |
|
MD5 | da666b3fe53ad08d7fe28e5973fd2627 |
|
BLAKE2b-256 | 60122d3ea2d438e4680577b5509cbd5468c34a26f647bd233867b948cdb853e1 |