Class FileAndResourceDirectives

Direct Known Subclasses:
FileUploadDirectives

public abstract class FileAndResourceDirectives extends ExecutionDirectives
Directives that load files and resources.

For the directives in this class, the "default classloader" is defined as the classloader that has loaded the akka.actor.ActorSystem class.

  • Constructor Details

    • FileAndResourceDirectives

      public FileAndResourceDirectives()
  • Method Details

    • defaultContentTypeResolver

      public ContentTypeResolver defaultContentTypeResolver()
    • defaultDirectoryRenderer

      public DirectoryRenderer defaultDirectoryRenderer()
      Default DirectoryRenderer to be used with directory listing directives.
    • getFromBrowseableDirectories

      public Route getFromBrowseableDirectories(String... directories)
      Serves the content of the given directories as a file system browser, i.e. files are sent and directories served as browseable listings.
      Parameters:
      directories - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectories

      public Route getFromBrowseableDirectories(Iterable<String> directories, DirectoryRenderer renderer, ContentTypeResolver resolver)
      Serves the content of the given directories as a file system browser, i.e. files are sent and directories served as browseable listings.
      Parameters:
      directories - (undocumented)
      renderer - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectories

      public Route getFromBrowseableDirectories(Iterable<String> directories, DirectoryRenderer renderer)
      Serves the content of the given directories as a file system browser, i.e. files are sent and directories served as browseable listings.
      Parameters:
      directories - (undocumented)
      renderer - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectories

      public Route getFromBrowseableDirectories(Iterable<String> directories, ContentTypeResolver resolver)
      Serves the content of the given directories as a file system browser, i.e. files are sent and directories served as browseable listings.
      Parameters:
      directories - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectories

      public Route getFromBrowseableDirectories(scala.collection.immutable.Seq<String> directories)
      Serves the content of the given directories as a file system browser, i.e. files are sent and directories served as browseable listings.
      Parameters:
      directories - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectory

      public Route getFromBrowseableDirectory(String directory, DirectoryRenderer renderer, ContentTypeResolver resolver)
      Same as getFromBrowseableDirectories with only one directory.
      Parameters:
      directory - (undocumented)
      renderer - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectory

      public Route getFromBrowseableDirectory(String directory, DirectoryRenderer renderer)
      Same as getFromBrowseableDirectories with only one directory.
      Parameters:
      directory - (undocumented)
      renderer - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectory

      public Route getFromBrowseableDirectory(String directory, ContentTypeResolver resolver)
      Same as getFromBrowseableDirectories with only one directory.
      Parameters:
      directory - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectory

      public Route getFromBrowseableDirectory(String directory)
      Same as getFromBrowseableDirectories with only one directory.
      Parameters:
      directory - (undocumented)
      Returns:
      (undocumented)
    • getFromDirectory

      public Route getFromDirectory(String directoryPath)
      Completes GET requests with the content of a file underneath the given directory, using the default content-type resolver. If the file cannot be read the Route rejects the request.
      Parameters:
      directoryPath - (undocumented)
      Returns:
      (undocumented)
    • getFromDirectory

      public Route getFromDirectory(String directoryPath, ContentTypeResolver resolver)
      Completes GET requests with the content of a file underneath the given directory, using the given content-type resolver. If the file cannot be read the Route rejects the request.
      Parameters:
      directoryPath - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromFile

      public Route getFromFile(File file)
      Completes GET requests with the content of the given file, resolving the content type using the default resolver. If the file cannot be found or read the request is rejected.
      Parameters:
      file - (undocumented)
      Returns:
      (undocumented)
    • getFromFile

      public Route getFromFile(File file, ContentTypeResolver resolver)
      Completes GET requests with the content of the given file, resolving the content type using the given resolver. If the file cannot be found or read the request is rejected.
      Parameters:
      file - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromFile

      public Route getFromFile(File file, ContentType contentType)
      Completes GET requests with the content of the given file, using the content type. If the file cannot be found or read the request is rejected.
      Parameters:
      file - (undocumented)
      contentType - (undocumented)
      Returns:
      (undocumented)
    • getFromFile

      public Route getFromFile(String file)
      Completes GET requests with the content of the given file, resolving the content type using the default resolver. If the file cannot be found or read the request is rejected.
      Parameters:
      file - (undocumented)
      Returns:
      (undocumented)
    • getFromFile

      public Route getFromFile(String file, ContentTypeResolver resolver)
      Completes GET requests with the content of the given file, resolving the content type using the given resolver. If the file cannot be found or read the request is rejected.
      Parameters:
      file - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromResource

      public Route getFromResource(String path)
      Completes GET requests with the content of the given resource loaded from the default ClassLoader, using the default content type resolver. If the resource cannot be found or read the Route rejects the request.
      Parameters:
      path - (undocumented)
      Returns:
      (undocumented)
    • getFromResource

      public Route getFromResource(String path, ContentTypeResolver resolver)
      Completes GET requests with the content of the given resource loaded from the default ClassLoader, using the given content type resolver. If the resource cannot be found or read the Route rejects the request.
      Parameters:
      path - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromResource

      public Route getFromResource(String path, ContentType contentType)
      Completes GET requests with the content of the given resource loaded from the default ClassLoader, with the given content type. If the resource cannot be found or read the Route rejects the request.
      Parameters:
      path - (undocumented)
      contentType - (undocumented)
      Returns:
      (undocumented)
    • getFromResource

      public Route getFromResource(String path, ContentType contentType, ClassLoader classLoader)
      Completes GET requests with the content of the given resource loaded from the given ClassLoader, with the given content type. If the resource cannot be found or read the Route rejects the request.
      Parameters:
      path - (undocumented)
      contentType - (undocumented)
      classLoader - (undocumented)
      Returns:
      (undocumented)
    • getFromResourceDirectory

      public Route getFromResourceDirectory(String directoryName)
      Same as "getFromDirectory" except that the file is not fetched from the file system but rather from a "resource directory", using the default ClassLoader, resolving content type using the default content type resolver.

      If the requested resource is itself a directory or cannot be found or read the Route rejects the request.

      Parameters:
      directoryName - (undocumented)
      Returns:
      (undocumented)
    • getFromResourceDirectory

      public Route getFromResourceDirectory(String directoryName, ClassLoader classLoader)
      Same as "getFromDirectory" except that the file is not fetched from the file system but rather from a "resource directory", using the given ClassLoader, resolving content type using the default content type resolver.

      If the requested resource is itself a directory or cannot be found or read the Route rejects the request.

      Parameters:
      directoryName - (undocumented)
      classLoader - (undocumented)
      Returns:
      (undocumented)
    • getFromResourceDirectory

      public Route getFromResourceDirectory(String directoryName, ContentTypeResolver resolver)
      Same as "getFromDirectory" except that the file is not fetched from the file system but rather from a "resource directory", using the default ClassLoader, resolving content type using the given content type resolver.

      If the requested resource is itself a directory or cannot be found or read the Route rejects the request.

      Parameters:
      directoryName - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromResourceDirectory

      public Route getFromResourceDirectory(String directoryName, ContentTypeResolver resolver, ClassLoader classLoader)
      Same as "getFromDirectory" except that the file is not fetched from the file system but rather from a "resource directory", using the given ClassLoader, resolving content type using the given content type resolver.

      If the requested resource is itself a directory or cannot be found or read the Route rejects the request.

      Parameters:
      directoryName - (undocumented)
      resolver - (undocumented)
      classLoader - (undocumented)
      Returns:
      (undocumented)
    • listDirectoryContents

      public Route listDirectoryContents(String... directories)
      Completes GET requests with a unified listing of the contents of all given directories. The actual rendering of the directory contents is performed by the in-scope Marshaller[DirectoryListing].
      Parameters:
      directories - (undocumented)
      Returns:
      (undocumented)
    • listDirectoryContents

      public Route listDirectoryContents(DirectoryRenderer directoryRenderer, String... directories)
      Completes GET requests with a unified listing of the contents of all given directories. The actual rendering of the directory contents is performed by the in-scope Marshaller[DirectoryListing].
      Parameters:
      directoryRenderer - (undocumented)
      directories - (undocumented)
      Returns:
      (undocumented)
    • listDirectoryContents

      public Route listDirectoryContents(scala.collection.immutable.Seq<String> directories)
      Completes GET requests with a unified listing of the contents of all given directories. The actual rendering of the directory contents is performed by the in-scope Marshaller[DirectoryListing].
      Parameters:
      directories - (undocumented)
      Returns:
      (undocumented)
    • listDirectoryContents

      public Route listDirectoryContents(DirectoryRenderer directoryRenderer, scala.collection.immutable.Seq<String> directories)
      Completes GET requests with a unified listing of the contents of all given directories. The actual rendering of the directory contents is performed by the in-scope Marshaller[DirectoryListing].
      Parameters:
      directoryRenderer - (undocumented)
      directories - (undocumented)
      Returns:
      (undocumented)