Use less freezing way of adding plugin subapps

This commit is contained in:
Tulir Asokan 2019-03-06 22:57:16 +02:00
parent e582cadb42
commit a4cfb97b67

View file

@ -18,6 +18,7 @@ import logging
import asyncio import asyncio
from aiohttp import web from aiohttp import web
from aiohttp.web_urldispatcher import PrefixedSubAppResource
from aiohttp.abc import AbstractAccessLogger from aiohttp.abc import AbstractAccessLogger
import pkg_resources import pkg_resources
@ -57,7 +58,8 @@ class MaubotServer:
return self.subapps[instance_id], url return self.subapps[instance_id], url
except KeyError: except KeyError:
app = web.Application(loop=self.loop) app = web.Application(loop=self.loop)
self.app.add_subapp(subpath, app) resource = PrefixedSubAppResource(subpath, app)
self.app.router.register_resource(resource)
self.subapps[instance_id] = app self.subapps[instance_id] = app
return app, url return app, url