1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Fix the "ping" response.

This commit is contained in:
Cedric Beust 2016-05-09 21:56:18 -08:00
parent 24134af985
commit b3403dba50
2 changed files with 10 additions and 2 deletions

View file

@ -20,6 +20,14 @@ import java.util.concurrent.Callable
class KobaltServer(val force: Boolean, val givenPort: Int? = null, class KobaltServer(val force: Boolean, val givenPort: Int? = null,
val initCallback: (String) -> List<Project>, val initCallback: (String) -> List<Project>,
val cleanUpCallback: () -> Unit) : Callable<Int> { val cleanUpCallback: () -> Unit) : Callable<Int> {
companion object {
/**
* Default response sent for calls that don't return a payload.
*/
val OK = "ok"
}
// var outgoing: PrintWriter? = null // var outgoing: PrintWriter? = null
interface IServer { interface IServer {

View file

@ -29,7 +29,7 @@ class SparkServer(val initCallback: (String) -> List<Project>, val cleanUpCallba
override fun run(port: Int) { override fun run(port: Int) {
Spark.port(port) Spark.port(port)
Spark.get("/ping", { req, res -> "The Kobalt server is up and running" }) Spark.get("/ping", { req, res -> KobaltServer.OK })
Spark.get("/quit", { req, res -> Spark.get("/quit", { req, res ->
Executors.newFixedThreadPool(1).let { executor -> Executors.newFixedThreadPool(1).let { executor ->
executor.submit { executor.submit {
@ -37,7 +37,7 @@ class SparkServer(val initCallback: (String) -> List<Project>, val cleanUpCallba
Spark.stop() Spark.stop()
executor.shutdown() executor.shutdown()
} }
"ok" KobaltServer.OK
} }
}) })
Spark.get("/v0/getDependencies", "application/json", Route { request, response -> Spark.get("/v0/getDependencies", "application/json", Route { request, response ->