2015-05-11 23:05:18 +02:00
|
|
|
.. _-head-:
|
|
|
|
|
|
|
|
|
|
head
|
|
|
|
|
====
|
|
|
|
|
|
|
|
|
|
Signature
|
|
|
|
|
---------
|
|
|
|
|
|
2015-06-19 15:35:24 +02:00
|
|
|
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/MethodDirectives.scala
|
2015-05-11 23:05:18 +02:00
|
|
|
:snippet: head
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
2015-10-09 15:19:36 +02:00
|
|
|
Matches requests with HTTP method ``HEAD``.
|
2015-05-11 23:05:18 +02:00
|
|
|
|
|
|
|
|
This directive filters the incoming request by its HTTP method. Only requests with
|
|
|
|
|
method ``HEAD`` are passed on to the inner route. All others are rejected with a
|
|
|
|
|
``MethodRejection``, which is translated into a ``405 Method Not Allowed`` response
|
|
|
|
|
by the default :ref:`RejectionHandler <The RejectionHandler>`.
|
|
|
|
|
|
2015-05-21 13:14:54 +02:00
|
|
|
.. note:: By default, akka-http handles HEAD-requests transparently by dispatching a GET-request to the handler and
|
|
|
|
|
stripping of the result body. See the ``akka.http.server.transparent-head-requests`` setting for how to disable
|
2015-05-11 23:05:18 +02:00
|
|
|
this behavior.
|
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
-------
|
|
|
|
|
|
2015-05-21 17:34:46 +02:00
|
|
|
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/MethodDirectivesExamplesSpec.scala
|
2015-05-11 23:05:18 +02:00
|
|
|
:snippet: head-method
|