Package spark
Class Service.StaticFiles
- java.lang.Object
-
- spark.Service.StaticFiles
-
- Enclosing class:
- Service
public final class Service.StaticFiles extends java.lang.Object
Provides static files utility methods.
-
-
Constructor Summary
Constructors Constructor Description StaticFiles()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disableMimeTypeGuessing()
Disables the automatic setting of Content-Type header made from a guess based on extension.void
expireTime(long seconds)
Sets the expire-time for static resourcesvoid
externalLocation(java.lang.String externalFolder)
Sets the external folder serving static files.void
header(java.lang.String key, java.lang.String value)
Puts custom header for static resources.void
headers(java.util.Map<java.lang.String,java.lang.String> headers)
Puts custom headers for static resources.void
location(java.lang.String folder)
Sets the folder in classpath serving static files.void
registerMimeType(java.lang.String extension, java.lang.String mimeType)
Maps an extension to a mime-type.
-
-
-
Method Detail
-
location
public void location(java.lang.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(java.lang.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(java.util.Map<java.lang.String,java.lang.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(java.lang.String key, java.lang.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 keyvalue
- 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(java.lang.String extension, java.lang.String mimeType)
Maps an extension to a mime-type. This will overwrite any previous mappings.- Parameters:
extension
- the extension to be mappedmimeType
- 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.
-
-