No project description provided
Project description
llsd-asgi
llsd-asgi
adds automatic LLSD content negotiation to ASGI applications
(Starlette, FastAPI, Quart, etc.) with a single line of code:
app.add_middleware(LLSDMiddleware)
The code for llsd-asgi
is based on msgpack-asgi, a similar middleware
library for the MessagePack binary format.
Installation
Install with pip:
pip install llsd-asgi
Quickstart (FastAPI)
You can use llsd-asgi
with FastAPI like so:
from fastapi import FastAPI
from llsd_asgi import LLSDMiddleware
app = FastAPI()
app.add_middleware(LLSDMiddleware)
Quickstart (Starlette)
As a lower level example using Starlette:
from llsd_asgi import LLSDMiddleware
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route
async def homepage(request):
return JSONResponse({"hello": "world"})
app = Starlette(debug=True, routes=[
Route('/', homepage),
])
# Wrap your application with the LLSD middleware
app = LLSDMiddleware(app)
How it works
flowchart TD
A(Client) <-->|LLSD| B(LLSDMiddleware)
B <-->|JSON| C(App)
Your ASGI application is wrapped around the LLSDMiddleware
, which performs
content negotiation based on Content-Type
and Accept
HTTP headers.
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
llsd-asgi-0.0.1.tar.gz
(8.4 kB
view details)
Built Distribution
File details
Details for the file llsd-asgi-0.0.1.tar.gz
.
File metadata
- Download URL: llsd-asgi-0.0.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5322b06bbd1d17ab0191533bbca1f94e4139d30ea574e276d1628a5590d6a838 |
|
MD5 | 6f467506af33a7f332f6304e76d9f19d |
|
BLAKE2b-256 | 2adf555eeec8e77b1bf4d8508de20deae243451fc2e06a57d07bc541c96244f9 |
File details
Details for the file llsd_asgi-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: llsd_asgi-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 988918d50d9bdc2fd938ee19ecb7528f1e2b90d20875209caafe797beb4d5234 |
|
MD5 | 4d561c03cbdb11164ae13307f103b255 |
|
BLAKE2b-256 | bc29894fb16171a32282ba6a48d17bd53a8d4bd2170bc7772c11f1a1c871c4fb |