Mercurial Hosting > luan
comparison core/src/luan/modules/host/Hosting.luan @ 742:5578541125ea
add Hosting.caller()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Jul 2016 17:47:30 -0600 |
parents | 6871ba08d521 |
children | 2c41f2aec92f |
comparison
equal
deleted
inserted
replaced
741:9f58b398a892 | 742:5578541125ea |
---|---|
2 | 2 |
3 local Luan = require "luan:Luan.luan" | 3 local Luan = require "luan:Luan.luan" |
4 local error = Luan.error | 4 local error = Luan.error |
5 local ipairs = Luan.ipairs or error() | 5 local ipairs = Luan.ipairs or error() |
6 local pairs = Luan.pairs or error() | 6 local pairs = Luan.pairs or error() |
7 local set_metatable = Luan.set_metatable or error() | |
7 local Io = require "luan:Io.luan" | 8 local Io = require "luan:Io.luan" |
8 local print = Io.print or error() | 9 local print = Io.print or error() |
9 local Rpc = require "luan:Rpc.luan" | 10 local Rpc = require "luan:Rpc.luan" |
10 local String = require "luan:String.luan" | 11 local String = require "luan:String.luan" |
11 local matches = String.matches or error() | 12 local matches = String.matches or error() |
84 local socket = "socket:" .. domain .. ":" .. M.port | 85 local socket = "socket:" .. domain .. ":" .. M.port |
85 local host = Rpc.remote(socket) | 86 local host = Rpc.remote(socket) |
86 return host.change_password(domain,old_password,new_password) | 87 return host.change_password(domain,old_password,new_password) |
87 end | 88 end |
88 | 89 |
90 function M.caller(domain) | |
91 local socket = "socket:" .. domain .. ":" .. M.port | |
92 local host = Rpc.remote(socket) | |
93 local mt = {} | |
94 function mt.__index(_,key) | |
95 return function(...) | |
96 return host.call(domain,key,...) | |
97 end | |
98 end | |
99 local t = {} | |
100 set_metatable(t,mt) | |
101 return t | |
102 end | |
103 | |
89 return M | 104 return M |