2015-05-11 23:05:18 +02:00
|
|
|
.. _-optionalHeaderValueByName-:
|
|
|
|
|
|
|
|
|
|
optionalHeaderValueByName
|
|
|
|
|
=========================
|
|
|
|
|
|
|
|
|
|
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: optionalHeaderValueByName
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
2015-10-09 15:19:36 +02:00
|
|
|
Optionally extracts the value of the HTTP request header with the given name.
|
2015-05-11 23:05:18 +02:00
|
|
|
|
2015-10-09 15:19:36 +02:00
|
|
|
The ``optionalHeaderValueByName`` directive is similar to the :ref:`-headerValueByName-` directive but always extracts
|
2015-05-11 23:05:18 +02:00
|
|
|
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: optionalHeaderValueByName-0
|