Mercurial Hosting > luan
comparison http/src/luan/modules/web/Http.luan @ 493:1d082a0812e0
move web to http
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 15 May 2015 17:29:59 -0600 |
parents | web/src/luan/modules/web/Http.luan@55a86fc4701b |
children |
comparison
equal
deleted
inserted
replaced
492:b36cc406d3d2 | 493:1d082a0812e0 |
---|---|
1 local Io = require "luan:Io" | |
2 | |
3 | |
4 | |
5 | |
6 function init_for_test() | |
7 | |
8 welcome_file = "index.html" | |
9 | |
10 function get_page(path) | |
11 if welcome_file ~= nil and path.matches ".*/" then | |
12 path = path .. welcome_file | |
13 end | |
14 local old_out = Io.stdout | |
15 local mod = require("site:"..path) | |
16 mod.service() | |
17 text_writer.close() | |
18 Io.stdout = old_out | |
19 return result.read_text() | |
20 end | |
21 | |
22 cookies = cookies or {} | |
23 | |
24 request = { | |
25 parameters = {}; | |
26 } | |
27 request.cookies = cookies | |
28 | |
29 response = { | |
30 | |
31 text_writer = function() | |
32 result = Io.uri "string:" | |
33 text_writer = result.text_writer() | |
34 return text_writer | |
35 end; | |
36 | |
37 set_cookie = function(name,value) | |
38 cookies[name] = value | |
39 end; | |
40 | |
41 remove_cookie = function(name) | |
42 cookies[name] = nil | |
43 end; | |
44 | |
45 send_redirect = function(url) | |
46 response.redirect = url | |
47 end; | |
48 | |
49 headers = {}; | |
50 | |
51 } | |
52 | |
53 end |