Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Setup hello world ktor server
Browse files Browse the repository at this point in the history
  • Loading branch information
tanettrimas committed Oct 27, 2023
1 parent 1d5e232 commit 57c5f89
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 20 additions & 3 deletions backend/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
id("org.jetbrains.kotlin.jvm") version "1.9.0"
id("io.ktor.plugin") version "2.3.5"


// Apply the application plugin to add support for building a CLI application in Java.
application
Expand All @@ -19,16 +21,25 @@ repositories {
}

dependencies {
val ktor_version = "2.3.5"
val logback_version = "1.4.11"
val slf4j_version = "2.0.9"

// Use the Kotlin JUnit 5 integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")

// Use the JUnit 5 integration.
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.3")

testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation("io.ktor:ktor-server-core-jvm:$ktor_version")
implementation("io.ktor:ktor-server-netty-jvm:$ktor_version")
implementation("io.ktor:ktor-server-content-negotiation:$ktor_version")
testImplementation("io.ktor:ktor-server-test-host:$ktor_version")

implementation("ch.qos.logback:logback-classic:$logback_version")
implementation("org.slf4j:slf4j-api:$slf4j_version")


// This dependency is used by the application.
implementation("com.google.guava:guava:32.1.1-jre")
}

// Apply a specific Java toolchain to ease working on different environments.
Expand All @@ -47,3 +58,9 @@ tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

ktor {
fatJar {
archiveFileName.set("fat.jar")
}
}
17 changes: 12 additions & 5 deletions backend/app/src/main/kotlin/backend/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
*/
package backend

class App {
val greeting: String
get() {
return "Hello World!"
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.response.*
import io.ktor.server.routing.*

fun server() = embeddedServer(factory = Netty, port = 8080) {
routing {
get {
call.respondText("Hello, world!")
}
}
}

fun main() {
println(App().greeting)
server().start(wait = true)
}

0 comments on commit 57c5f89

Please sign in to comment.