Mercurial Hosting > luan
view web/src/luan/modules/web/Http.luan @ 463:895afcd2b281
improve Http.init_for_test
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 06 May 2015 21:44:56 -0600 |
parents | 507c0af598ba |
children | 55a86fc4701b |
line wrap: on
line source
local Io = require "luan:Io" require "luan:logging/Logging" -- initialize logging 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