comparison src/luan/modules/http/tools/Dump_mod.luan @ 1088:bae2d0c2576c

change module naming convention
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 26 Dec 2016 22:29:36 -0700
parents e2eb55d86bb2
children d30d400fd43d
comparison
equal deleted inserted replaced
1087:4aab4dd3ac9c 1088:bae2d0c2576c
4 local Io = require "luan:Io.luan" 4 local Io = require "luan:Io.luan"
5 local Http = require "luan:http/Http.luan" 5 local Http = require "luan:http/Http.luan"
6 java() 6 java()
7 local HttpServicer = require "java:luan.modules.http.HttpServicer" 7 local HttpServicer = require "java:luan.modules.http.HttpServicer"
8 8
9 local M = {} 9 local Dump_mod = {}
10 10
11 local to_http_header_name = HttpServicer.toHttpHeaderName 11 local to_http_header_name = HttpServicer.toHttpHeaderName
12 M.to_http_header_name = to_http_header_name 12 Dump_mod.to_http_header_name = to_http_header_name
13 13
14 function M.respond() 14 function Dump_mod.respond()
15 Http.response.header.content_type = "text/plain" 15 Http.response.header.content_type = "text/plain"
16 Io.stdout = Http.response.text_writer() 16 Io.stdout = Http.response.text_writer()
17 17
18 local method = Http.request.method 18 local method = Http.request.method
19 local path = Http.request.path 19 local path = Http.request.path
22 path = path.."?"..query 22 path = path.."?"..query
23 end 23 end
24 %> 24 %>
25 <%=method%> <%=path%> <%=Http.request.protocol%> 25 <%=method%> <%=path%> <%=Http.request.protocol%>
26 <% 26 <%
27 M.dump_headers(Http.request.headers) 27 Dump_mod.dump_headers(Http.request.headers)
28 %> 28 %>
29 29
30 <% 30 <%
31 if method == "POST" and query ~= nil then 31 if method == "POST" and query ~= nil then
32 %> 32 %>
34 <% 34 <%
35 end 35 end
36 end 36 end
37 37
38 38
39 function M.dump_headers(headers) 39 function Dump_mod.dump_headers(headers)
40 for name, values in pairs(headers) do 40 for name, values in pairs(headers) do
41 local header_name = to_http_header_name(name) 41 local header_name = to_http_header_name(name)
42 for _, value in ipairs(values) do 42 for _, value in ipairs(values) do
43 %> 43 %>
44 <%=header_name%>: <%=value%> 44 <%=header_name%>: <%=value%>
45 <% 45 <%
46 end 46 end
47 end 47 end
48 end 48 end
49 49
50 return M 50 return Dump_mod