Skip to content

Instantly share code, notes, and snippets.

@juanpavergara
Last active August 29, 2015 14:17
Show Gist options
  • Save juanpavergara/5f3ef73b9caabb1e48eb to your computer and use it in GitHub Desktop.
Save juanpavergara/5f3ef73b9caabb1e48eb to your computer and use it in GitHub Desktop.
Función que recibe un futuro parametrizado y cuando finaliza con éxito hace un callback http a la url indicada con spray-client
def ejecutarCallBack[T](fut: Future[T], callback:String): Unit = {
fut onComplete {
case Success(x) => {
println(s"Haciendo callback a: $callback con body ${x.toString}")
val pipeline: HttpRequest => Future[HttpResponse] = sendReceive
val response: Future[HttpResponse] = pipeline(Post(callback, x.toString()))
}
case Failure(t) => println(s"Hubo una falla ${t.getMessage}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment