https://kotlinlang.org logo
Title
m

Marc Knaup

07/18/2021, 5:25 PM
Hey there 👋 Is there any solution by now to forward certain vert.x requests to Ktor? So that Ktor re-uses vert.x’ HTTP server and handles only certain routes.
b

Big Chungus

07/18/2021, 5:43 PM
have ktor routes under different port and proxy vert.x requests to
<http://localhost>:<KTOR_PORT>/<path>
?
m

Marc Knaup

07/18/2021, 5:44 PM
That’s my backup plan in case there’s no good solution 😅 Sounds nasty, esp. with websockets involved.
b

Big Chungus

07/18/2021, 5:44 PM
It IS nasty!
Alternatively you could reuse the same services from both, ktor and vert.x
m

Marc Knaup

07/18/2021, 6:01 PM
I can only use one HTTP port
r

Robert Jaros

07/18/2021, 6:01 PM
Why do you need to use both?
m

Marc Knaup

07/18/2021, 6:01 PM
I have a larger vert.x Java project that is to be migrated to Kotlin + Ktor over time. So migrated code would use Ktor route while old code would use vert.x route.
r

Robert Jaros

07/18/2021, 6:12 PM
What advantages gives Ktor vs Vert.x with Kotlin?
1
m

Marc Knaup

07/18/2021, 6:34 PM
We’re familiar with it.
k

kenkyee

07/18/2021, 7:23 PM
Why not migrate to Quarkus?
b

Big Chungus

07/18/2021, 7:24 PM
You could just as well ask "why not migrate to micronout". All of them are good in their own way. In the end it boils down to preference and familiarity...
1
👍 1
m

Marc Knaup

07/18/2021, 7:25 PM
Yup. Back on topic please 😄
r

Robert Jaros

07/18/2021, 7:37 PM
You could check the sources of
micronaut-ktor
module, which embeds Ktor inside Micronaut, reusing Micronaut's native http server. https://github.com/micronaut-projects/micronaut-kotlin/tree/master/ktor/src/main/kotlin/io/micronaut/ktor
m

Marc Knaup

07/18/2021, 8:45 PM
That replaces the existing HTTP server with Ktor instead of just adding Ktor as 2nd level
k

kenkyee

07/18/2021, 9:33 PM
Quarkus is vert.x underneath which is why I suggested it...
At any rate, doing a proxy is probably simplest but I'd suggest rewriting the websocket piece...