🏗️ Ktor Server lagt til

Co-authored-by: Amalie Erdal Mansaker <amalie.erdal.mansaker@nav.no>
Co-authored-by: Markus A. R. Johansen <markus.aleksander.rakil.johansen@nav.no>
This commit is contained in:
sindrekjelsrud 2023-07-03 15:00:27 +02:00
parent 941e2fe7ed
commit 1cb8e1713d
12 changed files with 195 additions and 114 deletions

36
backend/.gitignore vendored Normal file
View file

@ -0,0 +1,36 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/

View file

@ -1,27 +1,29 @@
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
plugins {
kotlin("jvm") version "1.8.21"
application
kotlin("jvm") version "1.8.22"
id("io.ktor.plugin") version "2.3.2"
}
group = "org.example"
version = "1.0-SNAPSHOT"
group = "no.nav.helse.sprik"
version = "0.0.1"
application {
mainClass.set("no.nav.helse.sprik.ApplicationKt")
val isDevelopment: Boolean = project.ext.has("development")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
}
repositories {
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(11)
}
application {
mainClass.set("MainKt")
implementation("io.ktor:ktor-server-core-jvm:$ktor_version")
implementation("io.ktor:ktor-server-netty-jvm:$ktor_version")
implementation("ch.qos.logback:logback-classic:$logback_version")
testImplementation("io.ktor:ktor-server-tests-jvm:$ktor_version")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
}

View file

@ -1 +1,4 @@
ktor_version=2.3.2
kotlin_version=1.8.22
logback_version=1.2.11
kotlin.code.style=official

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View file

@ -1,3 +1 @@
rootProject.name = "sprik-backend"
rootProject.name = "backend"

View file

@ -1,3 +0,0 @@
fun main(args: Array<String>) {
println("Hello World!")
}

View file

@ -0,0 +1,15 @@
package no.nav.helse.sprik
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import no.nav.helse.sprik.plugins.*
fun main() {
embeddedServer(Netty, port = 8080, host = "0.0.0.0", module = Application::module)
.start(wait = true)
}
fun Application.module() {
configureRouting()
}

View file

@ -0,0 +1,13 @@
package no.nav.helse.sprik.plugins
import io.ktor.server.routing.*
import io.ktor.server.response.*
import io.ktor.server.application.*
fun Application.configureRouting() {
routing {
get("/") {
call.respondText("Hello World!")
}
}
}

View file

@ -0,0 +1,12 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="trace">
<appender-ref ref="STDOUT"/>
</root>
<logger name="org.eclipse.jetty" level="INFO"/>
<logger name="io.netty" level="INFO"/>
</configuration>

View file

@ -0,0 +1,5 @@
package no.nav.helse.sprik
class ApplicationTest {
}