summary refs log tree commit diff
path: root/synapse/rest/client/v1/pusher.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2016-04-12 13:33:30 +0100
committerDavid Baker <dave@matrix.org>2016-04-12 13:33:30 +0100
commitd937f342bb223111a9cd6b2c4a8f0544e1a810a5 (patch)
treeb2f189e942b64ea32ea6899032cd53517e8a8d49 /synapse/rest/client/v1/pusher.py
parentAdd get endpoint for pushers (diff)
downloadsynapse-d937f342bb223111a9cd6b2c4a8f0544e1a810a5.tar.xz
Split into separate servlet classes
Diffstat (limited to 'synapse/rest/client/v1/pusher.py')
-rw-r--r--synapse/rest/client/v1/pusher.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/synapse/rest/client/v1/pusher.py b/synapse/rest/client/v1/pusher.py
index 5c88a9ba09..321eadbc24 100644
--- a/synapse/rest/client/v1/pusher.py
+++ b/synapse/rest/client/v1/pusher.py
@@ -26,18 +26,14 @@ import logging
 logger = logging.getLogger(__name__)
 
 
-class PusherRestServlet(ClientV1RestServlet):
-    PATTERNS = client_path_patterns("/pushers(/set)?$")
+class PushersRestServlet(ClientV1RestServlet):
+    PATTERNS = client_path_patterns("/pushers$")
 
     def __init__(self, hs):
-        super(PusherRestServlet, self).__init__(hs)
-        self.notifier = hs.get_notifier()
+        super(PushersRestServlet, self).__init__(hs)
 
     @defer.inlineCallbacks
     def on_GET(self, request):
-        if request.postpath != ["pushers"]:
-            defer.returnValue((405, {}))
-
         requester = yield self.auth.get_user_by_req(request)
         user = requester.user
 
@@ -63,11 +59,19 @@ class PusherRestServlet(ClientV1RestServlet):
 
         defer.returnValue((200, {"pushers": pushers}))
 
+    def on_OPTIONS(self, _):
+        return 200, {}
+
+
+class PushersSetRestServlet(ClientV1RestServlet):
+    PATTERNS = client_path_patterns("/pushers(/set)?$")
+
+    def __init__(self, hs):
+        super(PushersSetRestServlet, self).__init__(hs)
+        self.notifier = hs.get_notifier()
+
     @defer.inlineCallbacks
     def on_POST(self, request):
-        if request.postpath != ["pushers", "set"]:
-            defer.returnValue((405, {}))
-
         requester = yield self.auth.get_user_by_req(request)
         user = requester.user
 
@@ -133,4 +137,5 @@ class PusherRestServlet(ClientV1RestServlet):
 
 
 def register_servlets(hs, http_server):
-    PusherRestServlet(hs).register(http_server)
+    PushersRestServlet(hs).register(http_server)
+    PushersSetRestServlet(hs).register(http_server)