2015-05-11 23:05:18 +02:00
|
|
|
.. _-scheme-:
|
|
|
|
|
|
|
|
|
|
scheme
|
|
|
|
|
======
|
|
|
|
|
|
|
|
|
|
Signature
|
|
|
|
|
---------
|
|
|
|
|
|
2015-06-19 15:35:24 +02:00
|
|
|
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/SchemeDirectives.scala
|
2015-05-11 23:05:18 +02:00
|
|
|
:snippet: scheme
|
|
|
|
|
|
|
|
|
|
Description
|
|
|
|
|
-----------
|
2015-10-09 15:19:36 +02:00
|
|
|
Rejects a request if its Uri scheme does not match a given one.
|
2015-05-11 23:05:18 +02:00
|
|
|
|
|
|
|
|
The ``scheme`` directive can be used to match requests by their Uri scheme, only passing
|
|
|
|
|
through requests that match the specified scheme and rejecting all others.
|
|
|
|
|
|
|
|
|
|
A typical use case for the ``scheme`` directive would be to reject requests coming in over
|
|
|
|
|
http instead of https, or to redirect such requests to the matching https URI with a
|
|
|
|
|
``MovedPermanently``.
|
|
|
|
|
|
|
|
|
|
For simply extracting the scheme name, see the :ref:`-extractScheme-` directive.
|
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
-------
|
|
|
|
|
|
2015-09-16 23:50:35 +02:00
|
|
|
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/SchemeDirectivesExamplesSpec.scala
|
2015-05-11 23:05:18 +02:00
|
|
|
:snippet: example-2
|
|
|
|
|
|