This repository was archived by the owner on Jul 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
commonMain/kotlin/commands/cli
jvmMain/kotlin/commands/cli
macNativeMain/kotlin/commands/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
1717import io.ktor.server.plugins.cors.routing.CORS
1818import io.ktor.server.plugins.forwardedheaders.ForwardedHeaders
1919import io.ktor.server.response.respond
20+ import io.ktor.server.routing.Route
2021import io.ktor.server.routing.get
2122import io.ktor.server.routing.routing
2223import kotlinx.coroutines.Runnable
@@ -31,7 +32,7 @@ class ServeCommand(
3132) : Runnable {
3233
3334 @Serializable
34- private data class MessageResponse (val message : String )
35+ data class MessageResponse (val message : String )
3536
3637 private lateinit var server: BaseApplicationEngine
3738 private lateinit var storedRepos: List <Repository >
@@ -86,7 +87,7 @@ class ServeCommand(
8687 install(ContentNegotiation ) { json() }
8788
8889 routing {
89- get( " / " ) { call.respond( MessageResponse ( " Yep, it runs… " )) }
90+ setUpRoot()
9091 get(" /repos" ) { call.respond(storedRepos) }
9192 get(" /metrics" ) { call.respond(metricsByName) }
9293 get(" /time-series" ) { call.respond(metricsByNameTimeSeries) }
@@ -98,3 +99,5 @@ class ServeCommand(
9899 }
99100
100101}
102+
103+ expect fun Route.setUpRoot (): Route
Original file line number Diff line number Diff line change 1+ package commands.cli
2+
3+ import io.ktor.server.http.content.singlePageApplication
4+ import io.ktor.server.routing.Route
5+
6+ actual fun Route.setUpRoot (): Route = apply {
7+ singlePageApplication {
8+ useResources = true
9+ filesPath = " web"
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ package commands.cli
2+
3+ import commands.cli.ServeCommand.MessageResponse
4+ import io.ktor.server.application.call
5+ import io.ktor.server.response.respond
6+ import io.ktor.server.routing.Route
7+ import io.ktor.server.routing.get
8+
9+ actual fun Route.setUpRoot () = get(" /" ) {
10+ call.respond(MessageResponse (" UI runs only on the JVM" ))
11+ }
You can’t perform that action at this time.
0 commit comments