tests: add sav for nitrestful
authorAlexis Laferrière <alexis.laf@xymus.net>
Sun, 29 Nov 2015 05:06:52 +0000 (00:06 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Sun, 29 Nov 2015 05:15:52 +0000 (00:15 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

tests/nitrestful.args [new file with mode: 0644]
tests/sav/nitrestful.res [new file with mode: 0644]
tests/sav/nitrestful_args1.res [new file with mode: 0644]

diff --git a/tests/nitrestful.args b/tests/nitrestful.args
new file mode 100644 (file)
index 0000000..054e93a
--- /dev/null
@@ -0,0 +1 @@
+-o stdout ../lib/nitcorn/examples/src/restful_annot.nit
diff --git a/tests/sav/nitrestful.res b/tests/sav/nitrestful.res
new file mode 100644 (file)
index 0000000..c1bc443
--- /dev/null
@@ -0,0 +1,3 @@
+Usage: nitrestful [OPTION] module.nit [other_module.nit [...]]
+Generates the boilerplate code to link RESTful request to static Nit methods.
+Use --help for help
diff --git a/tests/sav/nitrestful_args1.res b/tests/sav/nitrestful_args1.res
new file mode 100644 (file)
index 0000000..e2947d2
--- /dev/null
@@ -0,0 +1,47 @@
+# This file is generated by nitrestful
+# Do not modify, instead refine the generated services.
+module restful_annot_rest
+
+import restful_annot
+
+redef class MyAction
+       redef fun answer(request, truncated_uri)
+       do
+               var verbs = truncated_uri.split("/")
+               if verbs.not_empty and verbs.first.is_empty then verbs.shift
+
+               if verbs.length != 1 then return super
+               var verb = verbs.first
+
+               if verb == "foo" then
+                       var in_s = request.string_arg("s")
+                       var out_s = in_s
+
+                       var in_i = request.string_arg("i")
+                       var out_i = deserialize_arg(in_i)
+
+                       var in_b = request.string_arg("b")
+                       var out_b = deserialize_arg(in_b)
+
+                       if not out_s isa String or not out_i isa Int or not out_b isa Bool then
+                               return super
+                       end
+                       return foo(out_s, out_i, out_b)
+               else if verb == "bar" then
+                       var in_s = request.string_arg("s")
+                       var out_s = in_s
+
+                       var in_i = request.string_arg("i")
+                       var out_i = deserialize_arg(in_i)
+
+                       var in_b = request.string_arg("b")
+                       var out_b = deserialize_arg(in_b)
+
+                       if not out_i isa nullable Int or not out_b isa nullable Bool then
+                               return super
+                       end
+                       return bar(out_s, out_i, out_b)
+               end
+               return super
+       end
+end