diff roundup/rest.py @ 6384:66a061e52435

Test options in rest interface against live server; rest doc update Add OPTIONS verb routing for /rest and /rest/data Document that there must not be a content-type header for OPTIONS or GET. Set TRACKER_WEB option in config.in to match where the server is running. Add testing for OPTIONS verb against all rest endpoint types.
author John Rouillard <rouilj@ieee.org>
date Wed, 21 Apr 2021 00:48:28 -0400
parents c1a672b1ad85
children 1fc765ef6379
line wrap: on
line diff
--- a/roundup/rest.py	Tue Apr 20 14:16:58 2021 -0400
+++ b/roundup/rest.py	Wed Apr 21 00:48:28 2021 -0400
@@ -1715,6 +1715,21 @@
 
         return 200, result
 
+    @Routing.route("/", 'OPTIONS')
+    @_data_decorator
+    def options_describe(self, input):
+        """OPTION return the HTTP Header for the root
+
+        Returns:
+            int: http status code 204 (No content)
+            body (string): an empty string
+        """
+        self.client.setHeader(
+            "Allow",
+            "OPTIONS, GET"
+        )
+        return 204, ""
+
     @Routing.route("/data")
     @_data_decorator
     def data(self, input):
@@ -1729,6 +1744,21 @@
                 result[cls] = dict(link=self.base_path + '/data/' + cls)
         return 200, result
 
+    @Routing.route("/data", 'OPTIONS')
+    @_data_decorator
+    def options_data(self, input):
+        """OPTION return the HTTP Header for the /data element
+
+        Returns:
+            int: http status code 204 (No content)
+            body (string): an empty string
+        """
+        self.client.setHeader(
+            "Allow",
+            "OPTIONS, GET"
+        )
+        return 204, ""
+
     @Routing.route("/summary")
     @_data_decorator
     def summary(self, input):

Roundup Issue Tracker: http://roundup-tracker.org/