=htp #20052 headerValueByType now works with custom headers

This commit is contained in:
Konrad Malawski 2016-03-16 15:03:47 +01:00
parent f34ef537f7
commit d83a323549
10 changed files with 106 additions and 19 deletions

View file

@ -7,6 +7,7 @@ package docs.http.scaladsl.server.directives
import akka.http.scaladsl.model._
import akka.http.scaladsl.server.MissingHeaderRejection
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.util.ClassMagnet
import docs.http.scaladsl.server.RoutingSpec
import headers._
import StatusCodes._

View file

@ -294,6 +294,8 @@ Strict-Transport-Security
__ @github@/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/ResponseRendererSpec.scala#L422
.. _custom-headers-scala:
Custom Headers
--------------

View file

@ -25,6 +25,13 @@ the given type is found the request is rejected with a ``MissingHeaderRejection`
If the header is expected to be missing in some cases or to customize handling when the header
is missing use the :ref:`-optionalHeaderValueByType-` directive instead.
.. note::
Custom headers will only be matched by this directive if they extend ``ModeledCustomHeader``
and provide a companion extending ``ModeledCustomHeaderCompanion``, otherwise the routing
infrastructure does now know where to search for the needed companion and header name.
To learn more about defining custom headers, read: :ref:`custom-headers-scala`.
Example
-------

View file

@ -22,6 +22,13 @@ Optionally extracts the value of the HTTP request header of the given type.
The ``optionalHeaderValueByType`` directive is similar to the :ref:`-headerValueByType-` directive but always extracts
an ``Option`` value instead of rejecting the request if no matching header could be found.
.. note::
Custom headers will only be matched by this directive if they extend ``ModeledCustomHeader``
and provide a companion extending ``ModeledCustomHeaderCompanion``, otherwise the routing
infrastructure does now know where to search for the needed companion and header name.
To learn more about defining custom headers, read: :ref:`custom-headers-scala`.
Example
-------