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")
10 redef fun prepare_respond_and_close(request, truncated_uri, http_server)
12 var resources = truncated_uri.split("/")
13 if resources.not_empty and resources.first.is_empty then resources.shift
15 if resources.length != 1 then
19 var resource = resources.first
21 if (resource == "foo") then
22 var in_s = request.string_arg("s")
25 var in_i = request.string_arg("i")
26 var out_i = deserialize_arg(in_i, "Int")
28 var in_b = request.string_arg("b")
29 var out_b = deserialize_arg(in_b, "Bool")
31 if out_s isa String and out_i isa Int and out_b isa Bool then
32 var response = foo(out_s, out_i, out_b)
33 http_server.respond response
38 if (resource == "api_name" or resource == "alt_name") and (request.method == "GET" or request.method == "PUT") then
39 var in_s = request.string_arg("s")
42 var in_i = request.string_arg("i")
43 var out_i = deserialize_arg(in_i, "nullable Int")
45 var in_b = request.string_arg("b")
46 var out_b = deserialize_arg(in_b, "nullable Bool")
48 if out_i isa nullable Int and out_b isa nullable Bool then
49 var response = bar(out_s, out_i, out_b)
50 http_server.respond response
55 if (resource == "async_service") then
56 var in_str = request.string_arg("str")
59 if out_str isa String then
60 var task = new Task_MyAction_async_service(self, request, http_server, out_str)
61 self.thread_pool.execute task
65 if (resource == "complex_args") then
66 var in_array = request.string_arg("array")
67 var out_array = deserialize_arg(in_array, "Array[String]")
69 var in_data = request.string_arg("data")
70 var out_data = deserialize_arg(in_data, "MyData")
72 if out_array isa Array[String] and out_data isa MyData then
73 var response = complex_args(out_array, out_data)
74 http_server.respond response
83 # Generated task to execute MyAction::async_service
84 class Task_MyAction_async_service
87 redef type A: MyAction
89 private var out_str: String
91 redef fun indirect_restful_method
93 return action.async_service(out_str)