Skip to content

Latest commit

 

History

History
40 lines (24 loc) · 1.57 KB

native_server.md

File metadata and controls

40 lines (24 loc) · 1.57 KB

Ktor supports Kotlin/Native and allows you to run a server without an additional runtime or virtual machine.

Limitations {id="limitations"}

Currently, running a Ktor server under Kotlin/Native has the following limitations:

  • only the CIO engine is supported
  • HTTPS without a reverse proxy is not supported
  • Windows target is not supported

Add dependencies {id="add-dependencies"}

To use Ktor server in a Kotlin/Native project, you need to add at least two dependencies: a ktor-server-core dependency and an engine dependency (CIO). The code snippet below shows how to add dependencies to the nativeMain source set in the build.gradle.kts file:

{src="snippets/embedded-server-native/build.gradle.kts" lines="32-38,44"}

Declare native binaries {id="binaries"}

To declare a native binary, use the binaries property of a native target:

{src="snippets/embedded-server-native/build.gradle.kts" lines="16-31"}

You can find the full example here: embedded-server-native.

Create a server {id="create-server"}

After configuring your Gradle build script, you can create a Ktor server as described here: .