pekko/akka-docs/rst/scala/http/routing-dsl/directives/header-directives/optionalHeaderValuePF.rst
2016-01-14 00:31:03 +01:00

24 lines
779 B
ReStructuredText

.. _-optionalHeaderValuePF-:
optionalHeaderValuePF
=====================
Signature
---------
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/HeaderDirectives.scala
:snippet: optionalHeaderValuePF
Description
-----------
Calls the specified partial function with the first request header the function is ``isDefinedAt`` and extracts the
result of calling the function.
The ``optionalHeaderValuePF`` directive is similar to the :ref:`-headerValuePF-` directive but always extracts an ``Option``
value instead of rejecting the request if no matching header could be found.
Example
-------
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/HeaderDirectivesExamplesSpec.scala
:snippet: optionalHeaderValuePF-0