2 LuCI - SGI-Module for WSAPI
5 Server Gateway Interface for WSAPI
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.wsapi", package.seeall)
28 require("luci.dispatcher")
29 require("luci.http.protocol")
31 function run(wsapi_env)
32 local r = luci.http.Request(wsapi_env, wsapi_env.input, wsapi_env.error)
33 r.postds = function() return wsapi.request.parse_post_data(wsapi_env) end
34 r.getds = function() return wsapi.request.parse_qs(wsapi_env.QUERY_STRING) end
36 local res, id, data1, data2 = true, 0, nil, nil
40 local x = coroutine.create(luci.dispatcher.httpdispatch)
42 res, id, data1, data2 = coroutine.resume(x, r)
46 headers["Content-Type"] = "text/plain"
48 return status, headers, function() local x = table.remove(err) return x end
54 headers[data1] = data2
59 local res, id, data1, data2 = coroutine.resume(x)
60 if not res or id == 5 then
67 return status, headers, iter