Created
January 31, 2014 01:00
-
-
Save mwylde/8724700 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
override def query(q: String) = { | |
import net.liftweb.json._ | |
import net.liftweb.json.JsonDSL._ | |
import net.liftweb.json.Serialization.{read, write} | |
implicit val formats = DefaultFormats | |
val futures = clients.map(_.query(q).map(hr => { | |
val list = (parse(hr.getContent.toString("UTF-8")) \ "results").children | |
list.map(_.extract[String]) | |
})) | |
Future.collect(futures).map(responses => { | |
val json = ("success" -> true) ~ ("results" -> responses.flatten.toList) | |
val response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK) | |
response.setContent(copiedBuffer(compact(render(json)), UTF_8)) | |
response | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment