dd00f63c370de26ac6112b614ee50a8504fd7eb9
[project/luci.git] / modules / rpc / luasrc / controller / rpc.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15 module("luci.controller.rpc", package.seeall)
16
17 function index()
18         local authenticator = function(validator)
19                 require "luci.jsonrpc"
20                 require "luci.http"
21                 luci.http.setfilehandler()
22                 
23                 local loginstat
24                 
25                 local server = {}
26                 server.login = function(...)
27                         loginstat = validator(...)
28                         return loginstat
29                 end
30                 
31                 luci.http.prepare_content("application/json")
32                 luci.http.write(luci.jsonrpc.handle(server, luci.http.content()))
33                 
34                 return loginstat
35         end
36         
37         uci = entry({"rpc", "uci"}, call("rpc_uci"))
38         uci.sysauth = "root"
39         uci.sysauth_authenticator = authenticator
40 end
41
42 function rpc_uci()
43         luci.http.write("HELLO THAR!")
44 end