uli
12/18/2022, 9:08 PMaddShutdownHook
as suggested for java:
applicationEngine.addShutdownHook {
println("Shutdown hook received")
println("Stopping engine")
applicationEngine.stop(200, 500)
println("Engine stopped")
}
applicationEngine.start(wait = true)
Norbi
12/19/2022, 5:24 PMHttpClient
throws BadContentTypeFormatException
, is there any way to work around it?Slackbot
12/21/2022, 1:08 PMAlex Cruise
12/21/2022, 10:25 PMZea
12/22/2022, 2:29 AMSerafeim Papastefanos
12/22/2022, 9:59 AMSerafeim Papastefanos
12/22/2022, 10:40 AMsrc/main/resources/application.conf
and works great. However, to deploy the app I create a fat jar. Is there a way to override some configuration options when I deploy that fat jar ? I know that I can use env vars but there are too many options that would need overriding. is it possible to pass another configuration file to the fatjar that would be used to override configuration options ? i.e run it like java -jar ktor-fat.jar -c local.conf
; when trying to read a configuration value, it will first check local.conf
, if not found then go to resources/application.conf
inside the jarEdoardo Maria Liotta
12/22/2022, 3:33 PMwww-authenticate: Bearer scope="" error="invalid_token" error_description="token contains an invalid number of segments"
but according to the Auth parser, this header is malformed (see stacktrace below). In the end, this causes refresh tokens never to be requested. Can you confirm whether this issue is on the parser or on AWS? Thank you in advance
Ktor and Auth plugin ver: 2.2.1
io.ktor.http.parsing.ParseException: Expected delimiter , at position 16, but found e
at io.ktor.http.auth.HttpAuthHeaderKt.skipDelimiter(HttpAuthHeader.kt:441)
at io.ktor.http.auth.HttpAuthHeaderKt.matchParameters(HttpAuthHeader.kt:141)
at io.ktor.http.auth.HttpAuthHeaderKt.parseAuthorizationHeader(HttpAuthHeader.kt:106)
at io.ktor.http.auth.HttpAuthHeaderKt.parseAuthorizationHeaders(HttpAuthHeader.kt:69)
at io.ktor.client.plugins.auth.Auth$Plugin$install$2.invokeSuspend(Auth.kt:58)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:205)
at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:135)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:109)
at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:11)
at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:59)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Andrey Tabakov
12/22/2022, 4:00 PMIvan Đorđević
12/23/2022, 1:29 PMSerafeim Papastefanos
12/23/2022, 1:50 PMAntonio Acuña Prieto
12/23/2022, 5:58 PMjwperez84
12/23/2022, 9:57 PMAndrey Tabakov
12/28/2022, 11:25 AMGradle Application plugin
?Виталий Перятин
12/26/2022, 4:53 PMdocker build -t finance-tracker .
my build FREEZING on this line: RUN gradle buildFatJar --no-daemon
If I execute gradle buildFatJar --no-daemon
in local terminal, application successfully build.
What do I need to do to fix it?Aminu Babayo Shehu
12/28/2022, 10:02 PMAminu Babayo Shehu
12/28/2022, 10:04 PMDocker
using this Dockerfile
Slackbot
12/29/2022, 8:39 AMSlackbot
12/29/2022, 1:20 PMMatti MK
12/29/2022, 2:13 PMContent-Type text/html; charset=UTF-8
. The response is as follows { "result": [ "foo", "bar" ] }
. When I try to serialize this into a POJO Ktor I get the following error:
No transformation found: class io.ktor.utils.io.ByteBufferChannel -> class FooList
This is most certainly about the wrong Content-Type
, but in this case I cannot change the serverMatti MK
12/29/2022, 2:16 PMContent-Type text/html; charset=UTF-8
. The response is as follows { "result": [ "foo", "bar" ] }
. When I try to serialize this into a POJO Ktor I get the following error:
No transformation found: class io.ktor.utils.io.ByteBufferChannel -> class FooList
This is most certainly about the wrong Content-Type
, as with valid application/json
header everything works as expected. Unfortunately, I cannot change the server’s headers.
Is there a workaround for this on client side? I tried with accept(ContentType.Text.Plain)
as well as accept(ContentType.Any)
but those don’t really help.rcd27
12/30/2022, 3:16 PMktor
with embeddedServer
using mockk
library. And we are facing some problems with mocking objects. What is the best way to test ktor
application? Assuming we need to mock some stuff that goes to third-party services? Any tough samples? Thanks.Sam Gammon
01/01/2023, 2:52 AMnative-image
is supported out of the box.
• 🚀 Trying it out
curl -sSL --tlsv1.2 dl.elide.dev/cli/install.sh | bash -s -
👆 the one liner works on Darwin (amd64/arm64), and Linux (amd64) so far.If you prefer NPX:
npx @elide-dev/elide@alpha shell
K Building Kotlin apps with it
•
Elide can be used as a plain library with a regular Micronaut server, and Ktor support is on the way. There are Maven artifacts in a custom repository which is easy to use during the alpha; you can see a sample here.
• G Gradle plugin
You can easily install the Gradle plugin to build your frontend assets and your Kotlin/JS, and package it into your server binary. It will handle building for SSR and CSR both, so you can easily switch between browser rendering modes. Check it out here. Maven and Bazel support are planned.
• 🖥️ Using the shell
elide shell
drops you into a shell just like Node (see attached screenshot), the difference being the URL
class we're using here is implemented in Kotlin, backed by the road-tested power of Micronaut, KotlinX, Netty, and the Java standard library. It has simply been adapted for use in JavaScript, according to the WhatWG URL Spec.
• js Use Kotlin/JS or regular Node stack
Elide packages and consumes your JS/TS with built-in support for esbuild
, so you can use a standard Node toolchain or the Kotlin/JS stack.
• 💨 Super fast React SSR
Because Elide is basically Kotlin with a super-fast JS runtime attached, it can do JS SSR without leaving the JVM. This can soon be drop-in compatible with many React apps. You can see a live sample here to confirm it is fast and server-rendered. The code for that sample is pasted below to show how simple it is to call back and forth between Kotlin and your React app:
@Page class Index : PageWithProps<YourProps>(YourProps.serializer()) {
// Serve React SSR.
@Get("/") suspend fun indexPage(request: HttpRequest<*>) = ssr(request) { // 1: tell the server we're going to do SSR for this request
head {
title { +"Hello, Elide!" }
stylesheet("/styles/base.css")
stylesheet("/styles/main.css")
script("/scripts/ui.js", defer = true) // <-- 2: serve the CSR bundle so it can hydrate the react SSR response
}
body {
injectSSR(this@Index, request) // <-- 3: execute the JS VM to produce the SSR response, and splice it into the server response
}
}
}
• 🐙 Contributors needed
The future of software is much more polyglot than today's paradigm: developers love to fight about frameworks, but at the end of the day, we're all writing code, and eliminating barriers between languages means easier collaboration and more value for all of us. It shouldn't be a Node vs. The World or a Rust vs. The World argument; we should get to pick and pull the best code we want from anywhere and use it to build our apps, especially from a multi-platform language like Kotlin.
This runtime and framework are designed for that future. *If you agree, join us and make a dent in the universe*; you'll have a chance to be impactful and shape a brave new idea from the ground up.
• 🙏 Thank you
We chose Kotlin because of the fantastic community. 2023 will be a massive year for Kotlin, and we think that betting the farm on it is reasonable and smart. We are super excited about what JetBrains and Kotlin have in store for us with K2, context receivers, value classes... just so much to look forward to.
Cheers and happy new year, Kotlin devs,
K sam
Posted in #feedAlexander Weickmann
01/01/2023, 7:09 PMTech
01/01/2023, 11:09 PMResource
serializable?Tech
01/02/2023, 1:53 PMChristiano
01/02/2023, 10:02 PMoauth
functionality for ktor. Instead of using a third party provider (like Google, Github,... ) I would like to have everything on my own server.
Is there any tutorial or guide to follow to set everything up? Is this even possible, because I can't seem to find anything about this... 😅Andreas Scheja
01/03/2023, 9:32 AMResponseSent
and ReceiveRequestBytes
hooks don't have suspending handlers? At least the latter is given a ByteReadChannel
so suspending calls should be quite common?Francisco Ripoli
01/03/2023, 3:45 PMSpring
projects, I had a separate maven project, just with a openapi yaml file, which I called the spec, and generated a jar file that would later be used on the actual service project, that way, both backend and fronted used that as a contract and we would not have issues with mismatching urls and request/response properties. I used to generate all that from my openapi yaml file using the openapi generator maven plugin … I’m trying to achieve something similar for ktor
but it seems impossible. I’ve tried many combinations of the settings for the plugin, but no luck. Is anyone doing something similar?CLOVIS
01/03/2023, 7:20 PMTRACE i.k.s.p.c.ContentNegotiation - Skipping because the type is ignored.
I'm using testApplication
with just the ContentNegotiation
plugin using KotlinX.Serialization
The test fails with 400 Bad Request with no provided body
, and Ktor seems to log that it decided to ignore the body for some reason?