* Last API changes before 0.4 API softfreeze
[project/luci.git] / core / src / ffluci / sgi / haserl.lua
1 --[[
2 FFLuCI - SGI-Module for Haserl
3
4 Description:
5 Server Gateway Interface for Haserl
6
7 FileId:
8 $Id$
9
10 License:
11 Copyright 2008 Steven Barth <steven@midlink.org>
12
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 
16
17         http://www.apache.org/licenses/LICENSE-2.0 
18
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.
24
25 ]]--
26 module("ffluci.sgi.haserl", package.seeall)
27
28 -- Environment Table
29 ffluci.http.env = ENV
30
31
32 -- Returns a table of all COOKIE, GET and POST Parameters
33 function ffluci.http.formvalues()
34         return FORM
35 end
36
37 -- Gets form value from key
38 function ffluci.http.formvalue(key, default)
39         local c = ffluci.http.formvalues()
40         
41         for match in key:gmatch("[%w-_]+") do
42                 c = c[match]
43                 if c == nil then
44                         return default
45                 end
46         end
47         
48         return c
49 end
50
51 -- Gets a table of values with a certain prefix
52 function ffluci.http.formvaluetable(prefix)
53         return ffluci.http.formvalue(prefix, {})
54 end
55
56
57 -- Set Content-Type
58 function ffluci.http.prepare_content(type)
59         print("Content-Type: "..type.."\n")
60 end
61
62 -- Sets HTTP-Status-Header
63 function ffluci.http.status(code, message)
64         print("Status: " .. tostring(code) .. " " .. message)
65 end