Skip to content

Instantly share code, notes, and snippets.

@rymdolle
Created August 2, 2020 21:17
Show Gist options
  • Save rymdolle/c062f79262d733bc11b1cb3547a6ba99 to your computer and use it in GitHub Desktop.
Save rymdolle/c062f79262d733bc11b1cb3547a6ba99 to your computer and use it in GitHub Desktop.
handler for .well-known/matrix/server
from well_known.handler import matrix
__all__ = ["matrix"]
from twisted.web.resource import Resource
from twisted.web.server import Request
import synapse.module_api
def matrix(config, module_api: synapse.module_api.ModuleApi) -> Resource:
res = Resource()
res.putChild(b"server", MyResource(module_api))
return res
def parse_config(config: dict):
return None
matrix.parse_config = parse_config
class MyResource(Resource):
def __init__(self, module_api: synapse.module_api.ModuleApi):
super().__init__()
self._module_api = module_api
def render_GET(self, request):
request.setHeader(b"Content-Type", b"application/json")
return b"""{"m.server": "rymdis.com:443"}"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment