I have a routes class (sender), an actor and a helper class. From the routes class, I send a request to the actor and get a Future response. Now, I want to pass the future response to the helper and resolve it there.
TestRoute.scala:
val response: Future[Any] = (actor ? request) (timeout)
handler(response)(executionContext)
TestHelper.scala:
def handler(futureResponse: Future[Any])(implicit ec: ExecutionContext): StandardRoute = {
onComplete(futureResponse) {
case Success(s) => complete(s)
case Failure(f) => reject
}
}
The problem is that while onComplete
works from within TestRoute.scala
, it does not work when moved to TestHelper.scala
. Any ideas what the problem might be?
EDIT: By "it does not work', I mean that the entire onComplete function is skipped over and not executed at all - no errors, just skips over.