Interface FileAndResourceDirectives

All Known Subinterfaces:
Directives
All Known Implementing Classes:
Directives$, FileAndResourceDirectives$

public interface FileAndResourceDirectives
  • Method Details

    • getFromFile

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> getFromFile(String fileName, ContentTypeResolver resolver)
      Completes GET requests with the content of the given file. If the file cannot be found or read the request is rejected.

      Parameters:
      fileName - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromFile

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> getFromFile(File file, ContentTypeResolver resolver)
      Completes GET requests with the content of the given file. If the file cannot be found or read the request is rejected.

      Parameters:
      file - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromFile

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> getFromFile(File file, ContentType contentType)
      Completes GET requests with the content of the given file. If the file cannot be found or read the request is rejected.

      Parameters:
      file - (undocumented)
      contentType - (undocumented)
      Returns:
      (undocumented)
    • conditionalFor

      Directive<scala.runtime.BoxedUnit> conditionalFor(long length, long lastModified)
    • getFromResource

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> getFromResource(String resourceName, ContentTypeResolver resolver)
      Completes GET requests with the content of the given class-path resource. If the resource cannot be found or read the Route rejects the request.

      A resource name that contains a .. segment, a backslash or a NUL character is rejected, unless the pekko.http.routing.reject-unsafe-resource-names setting is turned off. The directive does not otherwise know which prefix a name was built from, so validate any request-derived part of the name, or use getFromResourceDirectory, which serves only resources below the given directory.

      Parameters:
      resourceName - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromResource

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> getFromResource(String resourceName, ContentType contentType, ClassLoader classLoader)
      Completes GET requests with the content of the given resource. If the resource is a directory or cannot be found or read the Route rejects the request.

      Unsafe resource names are rejected as described for getFromResource(resourceName) above.

      Parameters:
      resourceName - (undocumented)
      contentType - (undocumented)
      classLoader - (undocumented)
      Returns:
      (undocumented)
    • serveResource

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> serveResource(String resourceName, ContentType contentType, ClassLoader classLoader, boolean useJarFileCache)
    • isSafeResourceName

      boolean isSafeResourceName(String resourceName)
      A resource name is unsafe when a .. segment could make it resolve outside the prefix it was built from: either a plain .. segment or one hidden behind a backslash, which a directory-backed class loader on Windows treats as a separator. NUL is rejected as no resource name can hold it.
      Parameters:
      resourceName - (undocumented)
      Returns:
      (undocumented)
    • getFromDirectory

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> getFromDirectory(String directoryName, ContentTypeResolver resolver)
      Completes GET requests with the content of a file underneath the given directory. If the file cannot be read the Route rejects the request.

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

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> listDirectoryContents(scala.collection.immutable.Seq<String> directories, FileAndResourceDirectives.DirectoryRenderer renderer)
      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)
      renderer - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectory

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> getFromBrowseableDirectory(String directory, FileAndResourceDirectives.DirectoryRenderer renderer, ContentTypeResolver resolver)
      Same as getFromBrowseableDirectories with only one directory.

      Parameters:
      directory - (undocumented)
      renderer - (undocumented)
      resolver - (undocumented)
      Returns:
      (undocumented)
    • getFromBrowseableDirectories

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> getFromBrowseableDirectories(scala.collection.immutable.Seq<String> directories, FileAndResourceDirectives.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)
    • getFromResourceDirectory

      scala.Function1<RequestContext,scala.concurrent.Future<RouteResult>> getFromResourceDirectory(String directoryName, ClassLoader classLoader, ContentTypeResolver resolver)
      Same as "getFromDirectory" except that the file is not fetched from the file system but rather from a "resource directory". If the requested resource is itself a directory or cannot be found or read the Route rejects the request.

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

      ClassLoader _defaultClassLoader()