mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Custom routes to Aiohttp web server.
Added opportunity to add custom routes to Aiohttp web server while setting webhook. Edited `start_webhook` method, now it takes `custom_routes` parameter (nested list of lists, e.g.: `[['GET', '/path', handler], ['POST', '/path2', handler_2]]`).
This commit is contained in:
parent
22094eb477
commit
a183122e8c
1 changed files with 9 additions and 4 deletions
|
|
@ -69,9 +69,9 @@ def set_webhook(dispatcher: Dispatcher, webhook_path: str, *, loop: Optional[asy
|
|||
return executor
|
||||
|
||||
|
||||
def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None,
|
||||
on_startup=None, on_shutdown=None, check_ip=False, retry_after=None, route_name=DEFAULT_ROUTE_NAME,
|
||||
**kwargs):
|
||||
def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None, on_startup=None, on_shutdown=None,
|
||||
check_ip=False, retry_after=None, route_name=DEFAULT_ROUTE_NAME,
|
||||
custom_routes: List[List[Union[str, str, Coroutine[Any, Any, Response]]]] = None, **kwargs):
|
||||
"""
|
||||
Start bot in webhook mode
|
||||
|
||||
|
|
@ -83,6 +83,7 @@ def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None,
|
|||
:param on_shutdown:
|
||||
:param check_ip:
|
||||
:param route_name:
|
||||
:param custom_routes:
|
||||
:param kwargs:
|
||||
:return:
|
||||
"""
|
||||
|
|
@ -95,8 +96,12 @@ def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None,
|
|||
check_ip=check_ip,
|
||||
retry_after=retry_after,
|
||||
route_name=route_name)
|
||||
executor.run_app(**kwargs)
|
||||
|
||||
if custom_routes != None:
|
||||
for route in custom_routes:
|
||||
executor.web_app.router.add_route(*route)
|
||||
|
||||
executor.run_app(**kwargs)
|
||||
|
||||
def start(dispatcher, future, *, loop=None, skip_updates=None,
|
||||
on_startup=None, on_shutdown=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue