Created
July 11, 2014 16:30
-
-
Save seanparsons/b0f5347d61e76307e26f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
path("metric" / Segment) { location => | |
val _uri = "http://<url>/api/crowd_api/metric?mode=Select&location=" + location | |
val _result = scala.io.Source.fromURL(_uri).mkString | |
val _xml = XML.loadString(_result) | |
val _crowd = _xml \\ "crowd" | |
case class Crowd(c_location: String, c_metric: String) | |
implicit def CrowdCodecJson: CodecJson[Crowd] = casecodec2(Crowd.apply, Crowd.unapply)("c_location", "c_metric") | |
val crowd_ = _crowd.map{ n => | |
val location = (n \ "location").text | |
val crowd_metric = (n \ "crowd_metric").text | |
("metric" := crowd_metric) ->: ("location" := location) ->: jEmptyObject | |
}.toList.asJson | |
val cm_output = crowd_ | |
get { ctx => ctx.complete(cm_output) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment