Skip to content

Commit 21a8658

Browse files
committed
fix(docs): add lifespan for fastapi
1 parent e4aa612 commit 21a8658

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

docs/engines/token-engine.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async def set_webhooks(app):
123123
await engine.add_bot("654321:UVWXYZ")
124124
```
125125

126-
`engine.register(app)` wires local framework callbacks. `engine.add_bot()` resolves the bot and calls Telegram.
126+
`engine.register(app)` registers the local route (with aiohttp, also wires lifecycle callbacks). For FastAPI, wrap startup in `engine.lifespan(app)` — see [FastAPI adapter](../web/fastapi.md). `engine.add_bot()` resolves the bot and calls Telegram.
127127

128128
### shutdown_timeout
129129

docs/index.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ blocks:
141141
142142
@asynccontextmanager
143143
async def lifespan(app: FastAPI):
144-
await engine.set_webhook()
145-
yield
144+
async with engine.lifespan(app):
145+
await engine.set_webhook()
146+
yield
146147
147148
148149
app = FastAPI(lifespan=lifespan)

docs/web/custom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Create a custom adapter when your web framework is not FastAPI or aiohttp. The a
44

55
`FastAPIAdapter` and `AiohttpAdapter` are shipped reference implementations — useful to read, not mandatory templates. Study their source when you need working lifecycle wiring or multipart reply handling:
66

7-
* `aiogram_webhook.web.fastapi`router lifespan, Starlette payload bridge
7+
* `aiogram_webhook.web.fastapi``engine.lifespan(app)` context manager pattern, Starlette payload bridge
88
* `aiogram_webhook.web.aiohttp``web.Application` routes and startup/shutdown hooks
99

1010
See also [Extending overview](../custom-integrations.md) for how adapters fit next to engines and security.

0 commit comments

Comments
 (0)