Package spark
Class Service.StaticFiles
java.lang.Object
spark.Service.StaticFiles
- Enclosing class:
Service
Provides static files utility methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDisables the automatic setting of Content-Type header made from a guess based on extension.voidexpireTime(long seconds) Sets the expire-time for static resourcesvoidexternalLocation(String externalFolder) Sets the external folder serving static files.voidPuts custom header for static resources.voidPuts custom headers for static resources.voidSets the folder in classpath serving static files.voidregisterMimeType(String extension, String mimeType) Maps an extension to a mime-type.
-
Constructor Details
-
StaticFiles
public StaticFiles()
-
-
Method Details
-
location
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
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
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
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
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.
-