跳转到主要内容

未提供项目描述

项目描述

llsd-asgi

llsd-asgi 使用一行代码为ASGI应用(Starlette、FastAPI、Quart等)添加自动 LLSD 内容协商

app.add_middleware(LLSDMiddleware)

llsd-asgi 的代码基于 msgpack-asgi,这是一个用于 MessagePack 二进制格式的类似中间件库。

安装

使用pip安装

pip install llsd-asgi

快速入门(FastAPI)

您可以使用 llsd-asgiFastAPI 如此

from fastapi import FastAPI
from llsd_asgi import LLSDMiddleware

app = FastAPI()
app.add_middleware(LLSDMiddleware)

快速入门(Starlette)

作为一个使用 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)

工作原理

flowchart TD
    A(Client) <-->|LLSD| B(LLSDMiddleware)
    B <-->|JSON| C(App)

您的ASGI应用程序被 LLSDMiddleware 包装,该中间件根据 Content-TypeAccept HTTP头进行内容协商。

怪癖模式

quirks=True 传递给中间件启用 🤪 怪癖模式。此模式的行为与表现不佳的Linden Lab服务相匹配,即使客户端没有请求,服务器也会返回LLSD。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

llsd-asgi-0.2.2.tar.gz (9.5 kB 查看哈希值)

上传时间 源代码

构建分发

llsd_asgi-0.2.2-py3-none-any.whl (5.1 kB 查看哈希值)

上传时间 Python 3

支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面