Mercurial Hosting > luan
comparison http/src/luan/modules/http/Http_test.luan @ 693:ca169567ce07
module URIs must now include ".luan"
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 19 Apr 2016 15:54:11 -0600 |
parents | 35dde32c02ab |
children | 87970832a3c3 |
comparison
equal
deleted
inserted
replaced
692:7bd97d642f37 | 693:ca169567ce07 |
---|---|
1 local Luan = require "luan:Luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local set_metatable = Luan.set_metatable or error() | 3 local set_metatable = Luan.set_metatable or error() |
4 local Io = require "luan:Io" | 4 local Io = require "luan:Io.luan" |
5 local String = require "luan:String" | 5 local String = require "luan:String.luan" |
6 local matches = String.matches or error() | 6 local matches = String.matches or error() |
7 local Http = require "luan:http/Http" | 7 local Http = require "luan:http/Http.luan" |
8 | 8 |
9 | 9 |
10 local M = {} | 10 local M = {} |
11 | 11 |
12 M.welcome_file = "index.html" | 12 M.welcome_file = "index.html" |
15 function M.get_page(path) | 15 function M.get_page(path) |
16 if M.welcome_file ~= nil and matches(path,"/$") then | 16 if M.welcome_file ~= nil and matches(path,"/$") then |
17 path = path .. M.welcome_file | 17 path = path .. M.welcome_file |
18 end | 18 end |
19 local old_out = Io.stdout | 19 local old_out = Io.stdout |
20 local mod = require("site:"..path) | 20 local mod = require("site:"..path..".luan") |
21 mod() | 21 mod() |
22 M.text_writer.close() | 22 M.text_writer.close() |
23 Io.stdout = old_out | 23 Io.stdout = old_out |
24 return M.result.read_text() | 24 return M.result.read_text() |
25 end | 25 end |