pekko/akka-docs/rst/scala/http/routing-dsl/directives/file-and-resource-directives/getFromBrowseableDirectory.rst

51 lines
1.8 KiB
ReStructuredText
Raw Normal View History

.. _-getFromBrowseableDirectory-:
getFromBrowseableDirectory
==========================
Signature
---------
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/FileAndResourceDirectives.scala
:snippet: getFromBrowseableDirectory
Description
-----------
2015-10-08 16:26:29 +02:00
The ``getFromBrowseableDirectories`` is a combination of serving files from the specified directories (like
``getFromDirectory``) and listing a browseable directory with ``listDirectoryContents``.
Nesting this directive beneath ``get`` is not necessary as this directive will only respond to ``GET`` requests.
Use ``getFromBrowseableDirectory`` to serve only one directory.
Use ``getFromDirectory`` if directory browsing isn't required.
For more details refer to :ref:`-getFromBrowseableDirectory-`.
Example
-------
2015-10-08 16:26:29 +02:00
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/FileAndResourceDirectivesExamplesSpec.scala
:snippet: getFromBrowseableDirectory-examples
Default file listing page example
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Directives which list directories (e.g. ``getFromBrowsableDirectory``) use an implicit ``DirectoryRenderer``
instance to perfm the actual rendering of the file listing. This rendered can be easily overriden by simply
providing one in-scope for the directives to use, so you can build your custom directory listings.
The default renderer is ``akka.http.scaladsl.server.directives.FileAndResourceDirectives.defaultDirectoryRenderer``,
and renders a listing which looks like this:
.. figure:: ../../../../../images/akka-http-file-listing.png
:scale: 75%
:align: center
Example page rendered by the ``defaultDirectoryRenderer``.
It's possible to turn off rendering the footer stating which version of Akka HTTP is rendering this page by configuring
the ``akka.http.routing.render-vanity-footer`` configuration option to ``off``.