Ky
06/20/2022, 6:59 PMHttpClient
kick off it’s own coroutine to make requests? And do we have any control over that coroutineContext?
I’m having trouble getting ktors HttpClient to behave nicely in regards to synchronization. Unless I wrap the .get()
in withContext(runTest.coroutineContext)
my tests do not wait for ktor request to return and the test will complete prematurelyChico
06/20/2022, 7:30 PMxxfast
06/21/2022, 2:32 AMHelio
06/21/2022, 11:31 AMonStopping, onPrepareStop and onStopped
ApplicationEvents are not triggered for Netty Engine? Is that expected? If so, do you have any suggestion to properly handle those Graceful Shutdowns?
Thanks once again for your help.cafonsomota
06/21/2022, 11:41 AMpublic suspend fun someCall(random: RandomObject): SomeObject = <http://client.post|client.post>(URL) {
setBody(random)
}.body()
Previously, when I called this from:
public suspend fun invokeSomeCall(random: RandomObject, onSuccess: (SomeObject) -> Unit, onFailure: (SomeErrorObject) -> Unit) {
try {
val response = EntityManagerAPI.someCall(random)
coroutineScope {
onSuccess(response)
}
} catch (e: Exception) {
coroutineScope {
onFailure(processException(e))
}
}
}
And the server returns a 403, the deserialization of SomeObject
would fail, and I’ll call onFailure
. Now, with the new version, onSuccess
is called and it’s deserialized with all the default values.
The rules that I’m using for Json
on ContentNegotation
are:
public val nonStrictJson: Json = Json {
prettyPrint = true
isLenient = true
ignoreUnknownKeys = true
}
From my tests if I change isLenient
to false, I get the previous behaviour; in any case I’m trying to understand what changed, or what I might be doing wrong?
Is there a better approach here? Perhaps, checking the status code before?David Smith
06/22/2022, 11:00 AMSean Proctor
06/22/2022, 12:22 PMsubham
06/22/2022, 1:33 PMe: Could not find "io.ktor:ktor-http-cio" in [/Users/subhamtyagi/Library/Application Support/kotlin/daemon]
e: java.lang.IllegalStateException: FATAL ERROR: Could not find "io.ktor:ktor-http-cio" in [/Users/subhamtyagi/Library/Application Support/kotlin/daemon]
Kotlin - 1.6.21
ktor-2.0.2
coroutine-1.6.3
More logs are in the threadTrey
06/22/2022, 8:19 PMAustin Pederson
06/22/2022, 9:46 PMCheick Kante
06/23/2022, 6:38 PMRaphael TEYSSANDIER
06/24/2022, 3:34 PMHamza GATTAL
06/25/2022, 10:40 PMLawrence
06/27/2022, 4:36 AMBao Le Duc
06/27/2022, 6:09 AMitzik kasovitch
06/27/2022, 8:46 AMAleksei Tirman [JB]
06/27/2022, 11:42 AMapplication.conf
from the main
sourceset if the config in the test
sourceset is absent?
:yes:
🇳🇴
John O'Reilly
06/27/2022, 1:07 PMRodrigo Silva
06/27/2022, 8:53 PMauthenticate {
("need_admin_role or user_role")
post("/some_route) { @TODO }
}
brabo-hi
06/28/2022, 12:02 AMcall.respondRedirect()
instead of rendering the new page call.respondTemplate('detail.ftl', mapOf("myData" to myValue))
however i need to send some data to the new page when rendering the templateSlackbot
06/28/2022, 7:43 AMram prasad
06/28/2022, 7:50 AM2.0.2
.
Basically I need to understand the setup(connection to test db and create data for testing) and teardown(cleanup of test data after all tests) parts using the testApplication
Thanks in advance!ram prasad
06/28/2022, 7:50 AMAndré Martins
06/28/2022, 8:23 AMreceive
method is an inline reified I cannot call it from java? Is there any other solution?Martin Gaens
06/28/2022, 12:45 PM.jar
), I get a NoClassDefFoundError
. This is the full stack trace:
Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/client/engine/cio/CIO
at com.gitlab.djsushi123.kotlintelegrambotmother.Bot.<init>(bot.kt:22)
at com.gitlab.djsushi123.kotlintelegrambotmother.BotKt.buildBot(bot.kt:57)
at MainKt.main(Main.kt:7)
at MainKt$main$2.invoke(Main.kt)
at MainKt$main$2.invoke(Main.kt)
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$1.invokeSuspend(IntrinsicsJvm.kt:205)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlin.coroutines.ContinuationKt.startCoroutine(Continuation.kt:115)
at kotlin.coroutines.jvm.internal.RunSuspendKt.runSuspend(RunSuspend.kt:19)
at MainKt.main(Main.kt)
Caused by: java.lang.ClassNotFoundException: io.ktor.client.engine.cio.CIO
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 10 more
What am I doing wrong? The library uses Gradle. This is my `build.gradle.kts`:
plugins {
id("org.jetbrains.kotlin.jvm") version "1.7.0"
kotlin("plugin.serialization") version "1.7.0"
`java-library`
}
version = "0.0.1-alpha"
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib")
api("io.ktor:ktor-client-core:2.0.2")
api("io.ktor:ktor-client-cio:2.0.2")
api("io.ktor:ktor-client-content-negotiation:2.0.2")
api("io.ktor:ktor-serialization-kotlinx-json:2.0.2")
api("io.ktor:ktor-client-resources:2.0.2")
// Use the Kotlin test library.
testImplementation("org.jetbrains.kotlin:kotlin-test")
// Use the Kotlin JUnit integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}
fbodr
06/28/2022, 12:47 PMSebastien Leclerc Lavallee
06/28/2022, 9:05 PM/account
or /events
that I would call at <http://localhost:8080/events>
for example.
Now I have deployed it on a server at something like <https://some.domain/api/>
and I call endpoints at <https://some.domain/api/events>
. Now there aren’t any route that is matched when I call that endpoint. I have an intercept where I print the request path and it says the path is /api/events
which makes sense.
My question is, how do I tell ktor that it’s hosted under a specific path ? In this case /api
. This way, it would strip the /api
part and the route would get matched and my code would run as expected.
Thanks 🙂fbodr
06/29/2022, 8:27 AMPaul Woitaschek
06/29/2022, 11:41 AMspierce7
06/29/2022, 3:44 PMspierce7
06/29/2022, 3:44 PMSatyam Agarwal
06/30/2022, 2:49 AMspierce7
06/30/2022, 2:52 AMSatyam Agarwal
06/30/2022, 3:17 AMspierce7
06/30/2022, 3:33 AMribesg
06/30/2022, 8:35 AM