Package spark

Class Service.StaticFiles

java.lang.Object
spark.Service.StaticFiles
Enclosing class:
Service

public final class Service.StaticFiles extends Object
Provides static files utility methods.
  • Constructor Details

    • StaticFiles

      public StaticFiles()
  • Method Details

    • location

      public void location(String folder)
      Sets the folder in classpath serving static files. Observe: this method must be called before all other methods.
      Parameters:
      folder - the folder in classpath.
    • externalLocation

      public void externalLocation(String externalFolder)
      Sets the external folder serving static files. Observe: this method must be called before all other methods.
      Parameters:
      externalFolder - the external folder serving static files.
    • headers

      public void headers(Map<String,String> headers)
      Puts custom headers for static resources. If the headers previously contained mapping for a specific key in the provided headers map, the old value is replaced by the specified value.
      Parameters:
      headers - the headers to set on static resources
    • header

      public void header(String key, String value)
      Puts custom header for static resources. If the headers previously contained a mapping for the key, the old value is replaced by the specified value.
      Parameters:
      key - the key
      value - the value
    • expireTime

      public void expireTime(long seconds)
      Sets the expire-time for static resources
      Parameters:
      seconds - the expire time in seconds
    • registerMimeType

      public void registerMimeType(String extension, String mimeType)
      Maps an extension to a mime-type. This will overwrite any previous mappings.
      Parameters:
      extension - the extension to be mapped
      mimeType - the mime-type for the extension
    • disableMimeTypeGuessing

      public void disableMimeTypeGuessing()
      Disables the automatic setting of Content-Type header made from a guess based on extension.