From 80f33eae37fff276f538ce43d2b0e18f773a839b Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 18 Apr 2020 20:20:21 +0200 Subject: Support for method annotations for compiler plugin (#142) --- .../kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 3 ++- .../jsMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 7 ++++--- .../jvmMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'kvision-modules/kvision-server-vertx/src') diff --git a/kvision-modules/kvision-server-vertx/src/commonMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-vertx/src/commonMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index 3ba4998d..c035e828 100644 --- a/kvision-modules/kvision-server-vertx/src/commonMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-vertx/src/commonMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -120,7 +120,8 @@ expect open class KVServiceManager(serviceClass: KClass) { * @param function a function of the receiver */ protected inline fun bindTabulatorRemote( - noinline function: suspend T.(Int?, Int?, List?, List?, String?) -> RemoteData + noinline function: suspend T.(Int?, Int?, List?, List?, String?) -> RemoteData, + route: String? = null ) /** diff --git a/kvision-modules/kvision-server-vertx/src/jsMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-vertx/src/jsMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index c7a35150..4927857f 100644 --- a/kvision-modules/kvision-server-vertx/src/jsMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-vertx/src/jsMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -150,9 +150,10 @@ actual open class KVServiceManager actual constructor(serviceClass: KCl * @param function a function of the receiver */ protected actual inline fun bindTabulatorRemote( - noinline function: suspend T.(Int?, Int?, List?, List?, String?) -> RemoteData + noinline function: suspend T.(Int?, Int?, List?, List?, String?) -> RemoteData, + route: String? ) { - val routeDef = "route${this::class.simpleName}${counter++}" + val routeDef = route ?: "route${this::class.simpleName}${counter++}" calls[function.toString().replace("\\s".toRegex(), "")] = Pair("/kv/$routeDef", HttpMethod.POST) } @@ -165,7 +166,7 @@ actual open class KVServiceManager actual constructor(serviceClass: KCl noinline function: suspend T.(ReceiveChannel, SendChannel) -> Unit, route: String? ) { - val routeDef = "route${this::class.simpleName}${counter++}" + val routeDef = route ?: "route${this::class.simpleName}${counter++}" calls[function.toString().replace("\\s".toRegex(), "")] = Pair("/kvws/$routeDef", HttpMethod.POST) } diff --git a/kvision-modules/kvision-server-vertx/src/jvmMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-server-vertx/src/jvmMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt index c64689b1..ae8b857c 100644 --- a/kvision-modules/kvision-server-vertx/src/jvmMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt +++ b/kvision-modules/kvision-server-vertx/src/jvmMain/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -417,7 +417,7 @@ actual open class KVServiceManager actual constructor(val serviceClass: noinline function: suspend T.(ReceiveChannel, SendChannel) -> Unit, route: String? ) { - val routeDef = "route${this::class.simpleName}${counter++}" + val routeDef = route ?: "route${this::class.simpleName}${counter++}" webSocketRequests["/kvws/$routeDef"] = { injector, ws -> val incoming = Channel() val outgoing = Channel() @@ -491,9 +491,10 @@ actual open class KVServiceManager actual constructor(val serviceClass: */ @Suppress("TooGenericExceptionCaught") protected actual inline fun bindTabulatorRemote( - noinline function: suspend T.(Int?, Int?, List?, List?, String?) -> RemoteData + noinline function: suspend T.(Int?, Int?, List?, List?, String?) -> RemoteData, + route: String? ) { - val routeDef = "route${this::class.simpleName}${counter++}" + val routeDef = route ?: "route${this::class.simpleName}${counter++}" addRoute(HttpMethod.POST, "/kv/$routeDef") { ctx -> val jsonRpcRequest = ctx.bodyAsJson.mapTo(JsonRpcRequest::class.java) @Suppress("MagicNumber") -- cgit