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.1.2.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

llsd_asgi-0.1.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llsd-asgi-0.1.2.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for llsd-asgi-0.1.2.tar.gz
Algorithm Hash digest
SHA256 15d006667470a281edcb0eee8ab7cc400283dd445a51ba49c77582c497e952b9
MD5 b70ae47aa8dfbdae34f5e6e8c7bad9f2
BLAKE2b-256 555549e7d41a88bcc0e18cc7083bad605ff5e8463db06d9570646e3c16bb861a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: llsd_asgi-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for llsd_asgi-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9dd5920a71a666439cb7cdad557cac8e9842fe71d76ae67f778ff269d76f14dc
MD5 7c1f76bfbb1eb44be444d7e01a74a37f
BLAKE2b-256 198475563420de89eb611fa6e7dc1c791ecd3f3f46dcd385ac1239541485cddd

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