Warning
THIS PROJECT IS ABANDONED! USE apkit.ActivityPubServer OR OTHER PROJECT!
apkit-litestar is currently focused on developing apkit/apmodel/apsig, so there are no plans to rewrite it at this time.
☄ litestar integration for apkit
$ pip install apkit-litestar
apkit-litestar can create responses that include models in apmodel format as content.
from apmodel import Note
from apkit_litestar import Response
from litestar import Litestar, get, Request
@get("/test")
def test(request: Request) -> Response:
return Response(content=Note(
content="test"
))
app = Litestar(
route_handlers=[test]
)Can be used like the starlette integration that comes with regular apkit
from apkit import APKit
from apkit_litestar import ActivityPubMiddleware
from apmodel import Create
from litestar import Litestar, Request
ap = APKit(
name="test",
description="test",
)
app = Litestar(
route_handlers=[],
middleware=[
ActivityPubMiddleware(apkit=ap)
]
)
@ap.on(Create)
async def on_create(request: Request, create: Create):
...