Merge: Revamp the C string to Nit string services to put forward the safest alternative
[nit.git] / tests / sav / nitrestful_args1.res
1 # This file is generated by nitrestful
2 # Do not modify, instead refine the generated services.
3 module restful_annot_rest is
4         no_warning("parentheses")
5 end
6
7 import restful_annot
8
9 redef class MyAction
10         redef fun answer(request, truncated_uri)
11         do
12                 var resources = truncated_uri.split("/")
13                 if resources.not_empty and resources.first.is_empty then resources.shift
14
15                 if resources.length != 1 then return super
16                 var resource = resources.first
17
18                 if (resource == "foo") then
19                         var in_s = request.string_arg("s")
20                         var out_s = in_s
21
22                         var in_i = request.string_arg("i")
23                         var out_i = deserialize_arg(in_i)
24
25                         var in_b = request.string_arg("b")
26                         var out_b = deserialize_arg(in_b)
27
28                         if not out_s isa String or not out_i isa Int or not out_b isa Bool then
29                                 return super
30                         end
31                         return foo(out_s, out_i, out_b)
32                 else if (resource == "api_name" or resource == "alt_name") and (request.method == "GET" or request.method == "PUT") then
33                         var in_s = request.string_arg("s")
34                         var out_s = in_s
35
36                         var in_i = request.string_arg("i")
37                         var out_i = deserialize_arg(in_i)
38
39                         var in_b = request.string_arg("b")
40                         var out_b = deserialize_arg(in_b)
41
42                         if not out_i isa nullable Int or not out_b isa nullable Bool then
43                                 return super
44                         end
45                         return bar(out_s, out_i, out_b)
46                 end
47                 return super
48         end
49 end