Return a string from a Future onComplete case with Scala and Spray.io
Spray have FutureMarshaller
, so you can return Future
itself.
def getFromElasticSearch: Future[String] = { val result: Future[SearchResponse] = get result onFailure { case t: Throwable => println("An error has occured: " + t) } result.map(someOperation)}
Should it not simply follow the pattern shown in the manual?
case Success(p) => complete(someOperations(p))