Query parameter reformatted to be more extensible and routing more robust

This commit is contained in:
Tyson 2013-01-09 11:29:22 -05:00
parent 0da2ff102e
commit bf9d9946f9
2 changed files with 6 additions and 6 deletions

View file

@ -22,13 +22,13 @@ class MasterWebUI(val actorSystem: ActorSystem, master: ActorRef) extends Direct
val handler = {
get {
(path("") & parameters('json ?)) {
case Some(js) =>
(path("") & parameters('format ?)) {
case Some(js) if js.equalsIgnoreCase("json") =>
val future = master ? RequestMasterState
respondWithMediaType(MediaTypes.`application/json`) { ctx =>
ctx.complete(future.mapTo[MasterState])
}
case None =>
case _ =>
completeWith {
val future = master ? RequestMasterState
future.map {

View file

@ -21,14 +21,14 @@ class WorkerWebUI(val actorSystem: ActorSystem, worker: ActorRef) extends Direct
val handler = {
get {
(path("") & parameters('json ?)) {
case Some(js) => {
(path("") & parameters('format ?)) {
case Some(js) if js.equalsIgnoreCase("json") => {
val future = worker ? RequestWorkerState
respondWithMediaType(MediaTypes.`application/json`) { ctx =>
ctx.complete(future.mapTo[WorkerState])
}
}
case None =>
case _ =>
completeWith{
val future = worker ? RequestWorkerState
future.map { workerState =>