2015-05-11 23:05:18 +02:00
|
|
|
.. _-optionalHeaderValue-:
|
|
|
|
|
|
|
|
|
|
optionalHeaderValue
|
|
|
|
|
===================
|
|
|
|
|
|
|
|
|
|
Traverses the list of request headers with the specified function and extracts the first value the function returns as
|
|
|
|
|
``Some(value)``.
|
|
|
|
|
|
|
|
|
|
Signature
|
|
|
|
|
---------
|
|
|
|
|
|
2015-06-19 15:35:24 +02:00
|
|
|
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/HeaderDirectives.scala
|
2015-05-11 23:05:18 +02:00
|
|
|
:snippet: optionalHeaderValue
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
The ``optionalHeaderValue`` directive is similar to the ``headerValue`` directive but always extracts an ``Option``
|
|
|
|
|
value instead of rejecting the request if no matching header could be found.
|
2015-10-01 13:25:41 +02:00
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/HeaderDirectivesExamplesSpec.scala
|
|
|
|
|
:snippet: optionalHeaderValue-0
|