tickets_plus.api.routes
Routes for the API.
A factory function for the API is provided, which takes a
tickets_plus.bot.TicketsPlusBot object and returns a
tornado.web.Application object.
Typical usage example:
from tickets_plus.api import routes from tickets_plus import bot bot_instance = bot.TicketsPlusBot(...) app = routes.make_app(bot_instance) app.listen(443, ssl_options=...)
1"""Routes for the API. 2 3A factory function for the API is provided, which takes a 4 :class:`tickets_plus.bot.TicketsPlusBot` object and returns a 5 :class:`tornado.web.Application` object. 6 7Typical usage example: 8 ```py 9 from tickets_plus.api import routes 10 from tickets_plus import bot 11 12 bot_instance = bot.TicketsPlusBot(...) 13 app = routes.make_app(bot_instance) 14 app.listen(443, ssl_options=...) 15 ``` 16""" 17# License: EPL-2.0 18# SPDX-License-Identifier: EPL-2.0 19# Copyright (c) 2021-present The Tickets+ Contributors 20# This Source Code may also be made available under the following 21# Secondary Licenses when the conditions for such availability set forth 22# in the Eclipse Public License, v. 2.0 are satisfied: GPL-3.0-only OR 23# If later approved by the Initial Contributor, GPL-3.0-or-later. 24 25from tornado import web 26 27from tickets_plus import bot 28from tickets_plus.api import handlers 29 30 31def make_app(bot_instance: bot.TicketsPlusBot) -> web.Application: 32 """Prepare the API. 33 34 Maps the routes to the handlers. Provides the bot object to the handlers. 35 36 Args: 37 bot_instance: The bot object. 38 """ 39 data = {"bot_instance": bot_instance} 40 routes = [ 41 (r"/", handlers.TicketHandler, data), 42 (r"/override", handlers.OverrideHandler, data), 43 ] 44 return web.Application(routes)
32def make_app(bot_instance: bot.TicketsPlusBot) -> web.Application: 33 """Prepare the API. 34 35 Maps the routes to the handlers. Provides the bot object to the handlers. 36 37 Args: 38 bot_instance: The bot object. 39 """ 40 data = {"bot_instance": bot_instance} 41 routes = [ 42 (r"/", handlers.TicketHandler, data), 43 (r"/override", handlers.OverrideHandler, data), 44 ] 45 return web.Application(routes)
Prepare the API.
Maps the routes to the handlers. Provides the bot object to the handlers.
Arguments:
- bot_instance: The bot object.