diff options
author | Daniel Wagner-Hall <dawagner@gmail.com> | 2015-12-01 17:36:37 +0000 |
---|---|---|
committer | Daniel Wagner-Hall <dawagner@gmail.com> | 2015-12-01 17:36:37 +0000 |
commit | 6e709799736ffb3c753f89376cb5b1c68f3cb17f (patch) | |
tree | f92b2d24bd243c3d91c0ca998f67fc5c7d2b95a3 /synapse/http/server.py | |
parent | Merge pull request #404 from matrix-org/markjh/trivial_rename (diff) | |
parent | Host /unstable and /r0 versions of r0 APIs (diff) | |
download | synapse-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/http/server.py')
-rw-r--r-- | synapse/http/server.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/synapse/http/server.py b/synapse/http/server.py index 50feea6f1c..ef75be742c 100644 --- a/synapse/http/server.py +++ b/synapse/http/server.py @@ -120,7 +120,7 @@ class HttpServer(object): """ Interface for registering callbacks on a HTTP server """ - def register_path(self, method, path_pattern, callback): + def register_paths(self, method, path_patterns, callback): """ Register a callback that gets fired if we receive a http request with the given method for a path that matches the given regex. @@ -129,7 +129,7 @@ class HttpServer(object): Args: method (str): The method to listen to. - path_pattern (str): The regex used to match requests. + path_patterns (list<SRE_Pattern>): The regex used to match requests. callback (function): The function to fire if we receive a matched request. The first argument will be the request object and subsequent arguments will be any matched groups from the regex. @@ -165,10 +165,11 @@ class JsonResource(HttpServer, resource.Resource): self.version_string = hs.version_string self.hs = hs - def register_path(self, method, path_pattern, callback): - self.path_regexs.setdefault(method, []).append( - self._PathEntry(path_pattern, callback) - ) + def register_paths(self, method, path_patterns, callback): + for path_pattern in path_patterns: + self.path_regexs.setdefault(method, []).append( + self._PathEntry(path_pattern, callback) + ) def render(self, request): """ This gets called by twisted every time someone sends us a request. |