diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-04-05 08:08:17 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-07-07 15:36:24 +0200 |
commit | 90288b2e2ca7e955983eaf0db59762351faa03fe (patch) | |
tree | 38720e02491e1baa5de52c8f0ed64c097d43e413 /modules/luci-base/htdocs/luci-static/resources/rpc.js | |
parent | eee323cb6683e6f1f1da7059e49eb8f4498bedf6 (diff) |
luci-base: rpc.js: make base URL configurable
Implement setters and getters for the base URL prefix used and also
implement a session ID getter while we're at it.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static/resources/rpc.js')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/rpc.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/rpc.js b/modules/luci-base/htdocs/luci-static/resources/rpc.js index cc22d0aeb4..36f5434d9c 100644 --- a/modules/luci-base/htdocs/luci-static/resources/rpc.js +++ b/modules/luci-base/htdocs/luci-static/resources/rpc.js @@ -3,7 +3,8 @@ var rpcRequestRegistry = {}, rpcRequestBatch = null, rpcRequestID = 1, - rpcSessionID = L.env.sessionid || '00000000000000000000000000000000'; + rpcSessionID = L.env.sessionid || '00000000000000000000000000000000', + rpcBaseURL = L.url('admin/ubus'); return L.Class.extend({ call: function(req, cbFn) { @@ -25,7 +26,7 @@ return L.Class.extend({ q += '/%s.%s'.format(req.params[1], req.params[2]); } - return L.Request.post(L.url('admin/ubus') + q, req, { + return L.Request.post(rpcBaseURL + q, req, { timeout: (L.env.rpctimeout || 5) * 1000, credentials: true }).then(cb); @@ -190,7 +191,19 @@ return L.Class.extend({ }, this, this, options); }, + getSessionID: function() { + return rpcSessionID; + }, + setSessionID: function(sid) { rpcSessionID = sid; + }, + + getBaseURL: function() { + return rpcBaseURL; + }, + + setBaseURL: function(url) { + rpcBaseURL = url; } }); |