Files
ghostnet-openclaw/tools/router/app/api/routes.py
T

37 lines
682 B
Python

from fastapi import Request
def register_routes(
app,
transport,
server
):
@app.get("/sse")
async def sse(
request: Request
):
async with transport.connect_sse(
request.scope,
request.receive,
request._send
) as (read, write):
await server.run(
read,
write,
server.create_initialization_options()
)
@app.post("/messages")
async def messages(
request: Request
):
await transport.handle_post_message(
request.scope,
request.receive,
request._send
)