2 LuCI - SGI-Module for Haserl
5 Server Gateway Interface for Haserl
8 $Id: haserl.lua 2027 2008-05-07 21:16:35Z Cyrus $
11 Copyright 2008 Steven Barth <steven@midlink.org>
13 Licensed under the Apache License, Version 2.0 (the "License");
14 you may not use this file except in compliance with the License.
15 You may obtain a copy of the License at
17 http://www.apache.org/licenses/LICENSE-2.0
19 Unless required by applicable law or agreed to in writing, software
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
26 module("luci.sgi.haserl", package.seeall)
29 require("luci.dispatcher")
32 local r = luci.http.Request()
34 r.request = normalize_table(FORM)
36 local x = coroutine.create(luci.dispatcher.httpdispatch)
37 while coroutine.status(x) ~= "dead" do
38 local res, id, data1, data2 = coroutine.resume(x, r)
41 print("Status: 500 Internal Server Error")
42 print("Content-Type: text/plain\n")
48 io.write("Status: " .. tostring(data1) .. " " .. data2 .. "\n")
50 io.write(data1 .. ": " .. data2 .. "\n")
59 function normalize_table(table, prefix)
60 prefix = prefix and prefix .. "." or ""
63 for k,v in pairs(table) do
64 if type(v) == "table" and #v == 0 then
65 luci.util.update(new, normalize_table(v, prefix .. k))