2015-05-11 23:05:18 +02:00
|
|
|
.. _-onComplete-:
|
|
|
|
|
|
|
|
|
|
onComplete
|
|
|
|
|
==========
|
|
|
|
|
|
|
|
|
|
Signature
|
|
|
|
|
---------
|
|
|
|
|
|
2015-06-19 15:35:24 +02:00
|
|
|
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/FutureDirectives.scala
|
2015-05-11 23:05:18 +02:00
|
|
|
:snippet: onComplete
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
2015-10-09 15:19:36 +02:00
|
|
|
Evaluates its parameter of type ``Future[T]``, and once the ``Future`` has been completed, extracts its
|
|
|
|
|
result as a value of type ``Try[T]`` and passes it to the inner route.
|
2015-05-21 17:34:46 +02:00
|
|
|
|
|
|
|
|
To handle the ``Failure`` case automatically and only work with the result value, use :ref:`-onSuccess-`.
|
2015-10-09 15:19:36 +02:00
|
|
|
|
2015-05-21 17:34:46 +02:00
|
|
|
To complete with a successful result automatically and just handle the failure result, use :ref:`-completeOrRecoverWith-`, instead.
|
2015-05-11 23:05:18 +02:00
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
-------
|
|
|
|
|
|
2015-05-21 17:34:46 +02:00
|
|
|
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/FutureDirectivesExamplesSpec.scala
|
|
|
|
|
:snippet: onComplete
|