How-to Guides
Status: 🔴 DA REVISIONARE
Task-focused recipes for the capabilities genro-asgi grows on top of the core. Each one assumes you have read Getting started and Core concepts.
The guides
Authentication — configure basic / bearer / JWT backends and API keys, protect routes with
auth_rule, and work with theAvataridentity.Sessions — arm the session subsystem, choose a memory or file store, control the session cookie, and attach an avatar at login.
OpenAPI & Swagger — turn
@routemethods into an OpenAPI 3.1 schema and a Swagger UI under the_metaprefix, direct or mounted.MCP — expose routes as tools an AI agent can call over MCP Streamable HTTP, standalone or side-by-side with REST.
Background tasks — arm the task backbone, fire off fire-and-forget work, schedule interval/cron jobs, and manage them over HTTP.
Streaming & SSE — return chunked bodies with
StreamingResponseand Server-Sent Events withSseStream.Middleware — the built-in chain, its order and defaults, how to arm each stage, and how to register a custom middleware.
How each guide is structured
Every how-to follows the same six-part shape, so you can skim to the part you need:
What it does — the capability in one or two sentences.
When to use it — the situation that calls for it.
Setup — the constructor kwargs or base class you need in place.
Minimal snippet — the smallest copy-pasteable example that works.
How to verify it — a concrete check (a
curl, a request, an observed effect) that proves it is working.Gotchas — the sharp edges worth knowing before you hit them.