Skip to main content

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

llsd-asgi-0.2.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

llsd_asgi-0.2.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file llsd-asgi-0.2.1.tar.gz.

File metadata

  • Download URL: llsd-asgi-0.2.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for llsd-asgi-0.2.1.tar.gz
Algorithm Hash digest
SHA256 546c58321d323971b095ffb755611b6293df71b4ce6ca3891890aa137a17eb0f
MD5 87ddebd699b85f57b79a8ea52a7cb93d
BLAKE2b-256 8d57c3825da52482ea439b7b4851ee757680fe1ebcad42c9342872d093aebe9e

See more details on using hashes here.

File details

Details for the file llsd_asgi-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: llsd_asgi-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for llsd_asgi-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 73ce78d7827e8fc44c7a880fbd0a06731b2d1e4140c5fee0ac04268bae9d7909
MD5 77669f6b3cfae72c6456da019f2e7ffa
BLAKE2b-256 56f18927ca077c7e199ace00218bb28b74d528b0f00c9051e5d11b5bf6f8817b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page