aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-01-18 22:44:57 +0100
committerRobert Jaros <rjaros@finn.pl>2020-01-18 22:44:57 +0100
commit7c1e742dcb0bb6708a7eaa015e8a16efea4fee8b (patch)
tree126aac9d78fc605698e8434767eb07c6b064e28e /kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision
parentd79881420b4564a4dfb40f13d3b0623b4fbc46ad (diff)
downloadkvision-7c1e742dcb0bb6708a7eaa015e8a16efea4fee8b.tar.gz
kvision-7c1e742dcb0bb6708a7eaa015e8a16efea4fee8b.tar.bz2
kvision-7c1e742dcb0bb6708a7eaa015e8a16efea4fee8b.zip
Add an option for an external URL prefix of remote KVision services
Diffstat (limited to 'kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision')
-rw-r--r--kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt6
1 files changed, 5 insertions, 1 deletions
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
index 0a56465d..58ba7368 100644
--- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
+++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/CallAgent.kt
@@ -23,9 +23,11 @@ package pl.treksoft.kvision.remote
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.stringify
+import org.w3c.dom.get
import pl.treksoft.jquery.JQueryAjaxSettings
import pl.treksoft.jquery.JQueryXHR
import pl.treksoft.jquery.jQuery
+import kotlin.browser.window
import kotlin.js.Promise
import kotlin.js.undefined
import kotlin.js.JSON as NativeJSON
@@ -40,6 +42,8 @@ const val HTTP_UNAUTHORIZED = 401
*/
open class CallAgent {
+ private val kvUrlPrefix = window["kv_remote_url_prefix"]
+ private val urlPrefix: String = if (kvUrlPrefix != undefined) kvUrlPrefix else ""
private var counter = 1
/**
@@ -63,7 +67,7 @@ open class CallAgent {
JSON.plain.stringify(jsonRpcRequest)
}
return Promise { resolve, reject ->
- jQuery.ajax(url, obj {
+ jQuery.ajax(urlPrefix + url, obj {
this.contentType = "application/json"
this.data = jsonData
this.method = method.name