diff options
author | chai <chaifix@163.com> | 2021-10-26 11:32:46 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-26 11:32:46 +0800 |
commit | 0549b1e5a8a3132005e275d6026db8003cb067d2 (patch) | |
tree | f0d7751ec32ecf5c4d23997fa0ffd3450a5a755a /Data/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua | |
parent | 32345800737b668011a87328cd3dcce59ec2934c (diff) |
*rename folder
Diffstat (limited to 'Data/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua')
-rw-r--r-- | Data/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Data/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua b/Data/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua new file mode 100644 index 0000000..f265b8a --- /dev/null +++ b/Data/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua @@ -0,0 +1,21 @@ +--
+-- jsonrpc.lua
+-- Installed in a CGILua webserver environment (with necessary CGI Lua 5.0 patch)
+--
+require ('json.rpcserver')
+
+-- The Lua class that is to serve JSON RPC requests
+local myServer = {
+ echo = function (msg) return msg end,
+ average = function(...)
+ local total=0
+ local count=0
+ for i=1, table.getn(arg) do
+ total = total + arg[i]
+ count = count + 1
+ end
+ return { average= total/count, sum = total, n=count }
+ end
+}
+
+json.rpcserver.serve(myServer)
\ No newline at end of file |