1 # This file is generated by nitrestful
2 # Do not modify, instead refine the generated services.
3 module restful_annot_rest is
5 no_warning("parentheses")
11 redef fun prepare_respond_and_close(request, truncated_uri, http_server)
13 var resources = truncated_uri.split("/")
14 if resources.not_empty and resources.first.is_empty then resources.shift
16 if resources.length != 1 then
20 var resource = resources.first
22 if (resource == "foo") then
23 var in_s = request.string_arg("s")
26 var in_i = request.string_arg("i")
27 var out_i = deserialize_arg(in_i, "Int")
29 var in_b = request.string_arg("b")
30 var out_b = deserialize_arg(in_b, "Bool")
32 if out_s isa String and out_i isa Int and out_b isa Bool then
33 var response = foo(out_s, out_i, out_b)
34 http_server.respond response
39 if (resource == "api_name" or resource == "alt_name") and (request.method == "GET" or request.method == "PUT") then
40 var in_s = request.string_arg("s")
43 var in_i = request.string_arg("i")
44 var out_i = deserialize_arg(in_i, "nullable Int")
46 var in_b = request.string_arg("b")
47 var out_b = deserialize_arg(in_b, "nullable Bool")
49 if out_i isa nullable Int and out_b isa nullable Bool then
50 var response = bar(out_s, out_i, out_b)
51 http_server.respond response
56 if (resource == "async_service") then
57 var in_str = request.string_arg("str")
60 if out_str isa String then
61 var task = new Task_MyAction_async_service(self, request, http_server, out_str)
62 self.thread_pool.execute task
66 if (resource == "complex_args") then
67 var in_array = request.string_arg("array")
68 var out_array = deserialize_arg(in_array, "Array[String]")
70 var in_data = request.string_arg("data")
71 var out_data = deserialize_arg(in_data, "MyData")
73 if out_array isa Array[String] and out_data isa MyData then
74 var response = complex_args(out_array, out_data)
75 http_server.respond response
84 # Generated task to execute MyAction::async_service
85 class Task_MyAction_async_service
88 redef type A: MyAction
90 private var out_str: String
92 redef fun indirect_restful_method
94 return action.async_service(out_str)