mirror of
https://github.com/maubot/maubot
synced 2025-09-05 02:30:38 +00:00
Proxy avatar requests through server and improve css
This commit is contained in:
parent
2aac4fbee1
commit
53d2264351
14 changed files with 92 additions and 90 deletions
|
@ -13,16 +13,25 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from aiohttp import web
|
||||
import logging
|
||||
import asyncio
|
||||
|
||||
from aiohttp import web
|
||||
from aiohttp.abc import AbstractAccessLogger
|
||||
|
||||
from mautrix.api import PathBuilder, Method
|
||||
|
||||
from .config import Config
|
||||
from .__meta__ import __version__
|
||||
|
||||
|
||||
class AccessLogger(AbstractAccessLogger):
|
||||
def log(self, request: web.Request, response: web.Response, time: int):
|
||||
self.logger.info(f'{request.remote} "{request.method} {request.path} '
|
||||
f'{response.status} {response.body_length} '
|
||||
f'in {round(time, 4)}s"')
|
||||
|
||||
|
||||
class MaubotServer:
|
||||
log: logging.Logger = logging.getLogger("maubot.server")
|
||||
|
||||
|
@ -39,7 +48,7 @@ class MaubotServer:
|
|||
as_path = PathBuilder(config["server.appservice_base_path"])
|
||||
self.add_route(Method.PUT, as_path.transactions, self.handle_transaction)
|
||||
|
||||
self.runner = web.AppRunner(self.app)
|
||||
self.runner = web.AppRunner(self.app, access_log_class=AccessLogger)
|
||||
|
||||
def add_route(self, method: Method, path: PathBuilder, handler) -> None:
|
||||
self.app.router.add_route(method.value, str(path), handler)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue