Initial commit
This commit is contained in:
20
server/src/main/kotlin/dev/ulfrx/recipe/Application.kt
Normal file
20
server/src/main/kotlin/dev/ulfrx/recipe/Application.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
package dev.ulfrx.recipe
|
||||
|
||||
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 main() {
|
||||
embeddedServer(Netty, port = SERVER_PORT, host = "0.0.0.0", module = Application::module)
|
||||
.start(wait = true)
|
||||
}
|
||||
|
||||
fun Application.module() {
|
||||
routing {
|
||||
get("/") {
|
||||
call.respondText("Ktor: ${Greeting().greet()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
12
server/src/main/resources/logback.xml
Normal file
12
server/src/main/resources/logback.xml
Normal 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>
|
||||
20
server/src/test/kotlin/dev/ulfrx/recipe/ApplicationTest.kt
Normal file
20
server/src/test/kotlin/dev/ulfrx/recipe/ApplicationTest.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
package dev.ulfrx.recipe
|
||||
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.testing.*
|
||||
import kotlin.test.*
|
||||
|
||||
class ApplicationTest {
|
||||
|
||||
@Test
|
||||
fun testRoot() = testApplication {
|
||||
application {
|
||||
module()
|
||||
}
|
||||
val response = client.get("/")
|
||||
assertEquals(HttpStatusCode.OK, response.status)
|
||||
assertEquals("Ktor: ${Greeting().greet()}", response.bodyAsText())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user