mirror of
https://github.com/maubot/maubot
synced 2025-09-05 02:30:38 +00:00
Make it run
This commit is contained in:
parent
eef052b1e9
commit
dce2771588
8 changed files with 88 additions and 28 deletions
|
@ -16,7 +16,7 @@
|
|||
from aiohttp import web
|
||||
import asyncio
|
||||
|
||||
from mautrix.api import PathBuilder
|
||||
from mautrix.api import PathBuilder, Method
|
||||
|
||||
from .config import Config
|
||||
from .__meta__ import __version__
|
||||
|
@ -29,13 +29,16 @@ class MaubotServer:
|
|||
self.config = config
|
||||
|
||||
path = PathBuilder(config["server.base_path"])
|
||||
self.app.router.add_get(path.version, self.version)
|
||||
self.add_route(Method.GET, path.version, self.version)
|
||||
|
||||
as_path = PathBuilder(config["server.appservice_base_path"])
|
||||
self.app.router.add_put(as_path.transactions, self.handle_transaction)
|
||||
self.add_route(Method.PUT, as_path.transactions, self.handle_transaction)
|
||||
|
||||
self.runner = web.AppRunner(self.app)
|
||||
|
||||
def add_route(self, method: Method, path: PathBuilder, handler) -> None:
|
||||
self.app.router.add_route(method.value, str(path), handler)
|
||||
|
||||
async def start(self) -> None:
|
||||
await self.runner.setup()
|
||||
site = web.TCPSite(self.runner, self.config["server.hostname"], self.config["server.port"])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue