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.
Quirks mode
Passing quirks=True
to the middleware enables 🤪 quirks mode. The behavior
of this mode matches that of poorly behaved Linden Lab services, where the
server returns LLSD even if the client has not requested it.
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
Built Distribution
File details
Details for the file llsd-asgi-0.1.1.tar.gz
.
File metadata
- Download URL: llsd-asgi-0.1.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43e564f3cbbde917ddba1781f25beb8d8899bb69d1414438ac1a722589b0050b |
|
MD5 | 3795508af38e4e09a92f3564fe33c934 |
|
BLAKE2b-256 | 4a886d2e74b0b48b3d4829e70ed959029694609b3f6ef8869f9991a156f3d817 |
File details
Details for the file llsd_asgi-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: llsd_asgi-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.0 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 | 94870b5ace037b6510fc59ecc73f2f9b493eed8c3ecf4f669e6bfe06734dd1fb |
|
MD5 | 732828c0c2b7c35f7966fa091598f60f |
|
BLAKE2b-256 | 4d9632e9c676f920624b17279fddcaf5d4b65e912009bf4b58e3dbe7c7bffe8c |