Skip to content

Instantly share code, notes, and snippets.

@eiennohito
Last active December 13, 2015 19:49
Show Gist options
  • Save eiennohito/4965878 to your computer and use it in GitHub Desktop.
Save eiennohito/4965878 to your computer and use it in GitHub Desktop.
Support for scala.concurrent.Future in Lift REST.
object Converter extends Loggable {
implicit def scalaconcfuture2LiftResponse[T <% LiftResponse](fut: Future[T])(implicit ec: ExecutionContext): () => Box[LiftResponse] = {
RestContinuation.async { finish =>
fut.onComplete {
case Success(res) => finish(res)
case Failure(ex) =>
logger.error("error when completing request", ex)
finish(InternalServerErrorResponse())
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment