summary refs log tree commit diff
path: root/synapse/rest/client/v1/base.py
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <dawagner@gmail.com>2015-12-01 17:36:37 +0000
committerDaniel Wagner-Hall <dawagner@gmail.com>2015-12-01 17:36:37 +0000
commit6e709799736ffb3c753f89376cb5b1c68f3cb17f (patch)
treef92b2d24bd243c3d91c0ca998f67fc5c7d2b95a3 /synapse/rest/client/v1/base.py
parentMerge pull request #404 from matrix-org/markjh/trivial_rename (diff)
parentHost /unstable and /r0 versions of r0 APIs (diff)
downloadsynapse-6e709799736ffb3c753f89376cb5b1c68f3cb17f.tar.xz
Merge pull request #400 from matrix-org/daniel/versioning
Merge pull request # 400 from matrix-org/daniel/versioning
Diffstat (limited to 'synapse/rest/client/v1/base.py')
-rw-r--r--synapse/rest/client/v1/base.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/rest/client/v1/base.py b/synapse/rest/client/v1/base.py
index 504a5e432f..7ae3839a19 100644
--- a/synapse/rest/client/v1/base.py
+++ b/synapse/rest/client/v1/base.py
@@ -27,7 +27,7 @@ import logging
 logger = logging.getLogger(__name__)
 
 
-def client_path_pattern(path_regex):
+def client_path_patterns(path_regex, releases=(0,)):
     """Creates a regex compiled client path with the correct client path
     prefix.
 
@@ -37,7 +37,13 @@ def client_path_pattern(path_regex):
     Returns:
         SRE_Pattern
     """
-    return re.compile("^" + CLIENT_PREFIX + path_regex)
+    patterns = [re.compile("^" + CLIENT_PREFIX + path_regex)]
+    unstable_prefix = CLIENT_PREFIX.replace("/api/v1", "/unstable")
+    patterns.append(re.compile("^" + unstable_prefix + path_regex))
+    for release in releases:
+        new_prefix = CLIENT_PREFIX.replace("/api/v1", "/r%d" % release)
+        patterns.append(re.compile("^" + new_prefix + path_regex))
+    return patterns
 
 
 class ClientV1RestServlet(RestServlet):