Added a urls module for keeping client and federation prefixes.

This commit is contained in:
Kegan Dougal 2014-08-14 11:52:56 +01:00
parent 9fd445eb92
commit c75add6ec8
5 changed files with 23 additions and 14 deletions

19
synapse/api/urls.py Normal file
View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2014 matrix.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Contains the URL paths to prefix various aspects of the server with. """
CLIENT_PREFIX = "/matrix/client/api/v1"
FEDERATION_PREFIX = "/matrix/federation/v1"

View File

@ -26,8 +26,7 @@ from twisted.web.static import File
from twisted.web.server import Site
from synapse.http.server import JsonResource, RootRedirect
from synapse.http.client import TwistedHttpClient
from synapse.rest.base import CLIENT_PREFIX
from synapse.federation.transport import PREFIX
from synapse.api.urls import CLIENT_PREFIX, FEDERATION_PREFIX
from daemonize import Daemonize
@ -101,7 +100,7 @@ class SynapseHomeServer(HomeServer):
# [ ("/aaa/bbb/cc", Resource1), ("/aaa/dummy", Resource2) ]
desired_tree = [
(CLIENT_PREFIX, self.get_resource_for_client()),
(PREFIX, self.get_resource_for_federation())
(FEDERATION_PREFIX, self.get_resource_for_federation())
]
if web_client:
logger.info("Adding the web client.")

View File

@ -23,6 +23,7 @@ over a different (albeit still reliable) protocol.
from twisted.internet import defer
from synapse.api.urls import FEDERATION_PREFIX as PREFIX
from synapse.util.logutils import log_function
import logging
@ -33,9 +34,6 @@ import re
logger = logging.getLogger(__name__)
PREFIX = "/matrix/federation/v1"
class TransportLayer(object):
"""This is a basic implementation of the transport layer that translates
transactions and other requests to/from HTTP.

View File

@ -20,17 +20,11 @@ from ._base import BaseHandler
from synapse.api.errors import SynapseError
import logging
import json
import urllib
logger = logging.getLogger(__name__)
# TODO(erikj): This needs to be factored out somewere
PREFIX = "/matrix/client/api/v1"
class DirectoryHandler(BaseHandler):
def __init__(self, hs):

View File

@ -14,10 +14,9 @@
# limitations under the License.
""" This module contains base REST classes for constructing REST servlets. """
from synapse.api.urls import CLIENT_PREFIX
import re
CLIENT_PREFIX = "/matrix/client/api/v1"
def client_path_pattern(path_regex):
"""Creates a regex compiled client path with the correct client path