Skip to content

Latest commit

 

History

History
50 lines (30 loc) · 2.04 KB

File metadata and controls

50 lines (30 loc) · 2.04 KB
Ktor supports Kotlin/Native and allows you to run a server without an additional runtime or virtual machine.

Ktor supports Kotlin/Native and allows you to run a server without an additional runtime or virtual machine. Currently, running a Ktor server under Kotlin/Native has the following limitations:

Add dependencies {id="add-dependencies"}

Ktor server in a Kotlin/Native project requires 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" include-lines="33-39,46"}

To test a Native server, add the ktor-server-test-host artifact to the nativeTest source set:

{src="snippets/embedded-server-native/build.gradle.kts" include-lines="33,40-46"}

Configure native targets {id="native-target"}

Specify the required native targets and declare a native binary using the binaries property:

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

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: .