getFromBrowseableDirectories

Signature

def getFromBrowseableDirectories(directories: String*)(implicit renderer: DirectoryRenderer, resolver: ContentTypeResolver): Route

Description

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 getFromBrowseableDirectory.

Example

Scala
sourceval route =
  path("tmp") {
    getFromBrowseableDirectories("/main", "/backups")
  }

// tests:
Get("/tmp") ~> route ~> check {
  status shouldEqual StatusCodes.OK
}
Java
sourceimport static akka.http.javadsl.server.Directives.getFromBrowseableDirectories;
import static akka.http.javadsl.server.Directives.path;

final Route route = path("tmp", () ->
  getFromBrowseableDirectories("/main", "/backups")
);

// tests:
testRoute(route).run(HttpRequest.GET("/tmp"))
  .assertStatusCode(StatusCodes.OK);
Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.