Mercurial Hosting > luan
view 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 |
line wrap: on
line source
local Io = require "luan:Io" function init_for_test() welcome_file = "index.html" function get_page(path) if welcome_file ~= nil and path.matches ".*/" then path = path .. welcome_file end local old_out = Io.stdout local mod = require("site:"..path) mod.service() text_writer.close() Io.stdout = old_out return result.read_text() end cookies = cookies or {} request = { parameters = {}; } request.cookies = cookies response = { text_writer = function() result = Io.uri "string:" text_writer = result.text_writer() return text_writer end; set_cookie = function(name,value) cookies[name] = value end; remove_cookie = function(name) cookies[name] = nil end; send_redirect = function(url) response.redirect = url end; headers = {}; } end