hey I'm evaluating kilua for an existing project. ...
# kilua
a
hey I'm evaluating kilua for an existing project. the server is mainly a ktor rest API for thick client applications. But I have a small web front end as well. Currently I'm using the now deprecated kweb framework, so I need a replacement. I'd really like to not touch the rest end points and just leave them as pure ktor routes. kweb was able to just capture any routes that were not otherwise handled, which made it work really well as just part of a larger ktor project. can anyone think of a way to integrate kilua similarly? as just part of an existing ktor application?
r
Kweb is a server side project, so you can't just replace it with a client side application. But you can use Kilua app inside a fullstack Ktor project. Have you checked the
ssr-ktor
example?
In general this code is all you need to use single page application with Ktor: https://github.com/rjaros/kilua-rpc/blob/main/modules/kilua-rpc-ktor-koin/src/jvmMain/kotlin/dev/kilua/rpc/RpcModules.kt#L77-L85 You just need to bundle the output files with Ktor jar. Kilua RPC gradle plugin can do it for you.
You will probably need to handle some routes inside you Kilua application. Use the
kilua-routing
module or
kilua-ssr
module if you want to support SSR. And to access your Ktor endpoints you can use
RestClient
class from the
kilua-rest
module.
a
okay great, that looks like it'll work out, thanks!