Ktor Native Server Example
This repository contains a sample Ktor 2.0 server program that runs only with Kotlin/Native.
The server includes the following functionalities:
- SQLDelight Postgrs connection
- Uses (first available) native postgres driver from Philip Wedemann
- Sample REST API with KotlinX JSON Serialization
- Global error handling middleware
- Sample Application Plugin (Middleware) for request logging
The ktor server is running with CIO Engine (Coroutine-based I/O) which is the only on supported by Kotlin/Native (Netty, Jetty and Tomcat are JVM based). More general information can be found here: https://ktor.io/docs/native-server.html
Supported Platforms
- Linux (x64, Arm64)
- MacOS (x64, Arm64)
How to run
- Start Postgres instance
docker compose up
- Debug
./gradlew runDebugExecutable
Tests:
./gradlew allTests
Known Problems
- Problems with tests in IntelliJ: Cannot access class 'io.ktor...'. Check your module classpath for missing or
conflicting dependencies
- Open bug
can be overcome by adding following to
gradle.properties
kotlin.mpp.hierarchicalStructureSupport=false
- Open bug
can be overcome by adding following to
Planned Features
- Database connection via Exposed once supported