2015-05-11 23:05:18 +02:00
|
|
|
.. _-extractMethod-:
|
|
|
|
|
|
|
|
|
|
extractMethod
|
|
|
|
|
=============
|
|
|
|
|
|
|
|
|
|
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: extractMethod
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
2015-10-01 13:25:41 +02:00
|
|
|
Extracts the :class:`HttpMethod` from the request context and provides it for use for other directives explicitly.
|
2015-05-11 23:05:18 +02:00
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
-------
|
|
|
|
|
|
2015-10-01 13:25:41 +02:00
|
|
|
In the below example our route first matches all ``GET`` requests, and if an incoming request wasn't a ``GET``,
|
|
|
|
|
the matching continues and the extractMethod route will be applied which we can use to programatically
|
|
|
|
|
print what type of request it was - independent of what actual HttpMethod it was:
|
|
|
|
|
|
2015-09-16 23:50:35 +02:00
|
|
|
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/MethodDirectivesExamplesSpec.scala
|
2015-10-01 13:25:41 +02:00
|
|
|
:snippet: extractMethod-example
|