object Assets
Type Members
- case class Asset(name: String) extends Product with Serializable
Value Members
- final def !=(arg0: Any): Boolean
- final def ##: Int
- final def ==(arg0: Any): Boolean
- val alternativeDateFormatWithTZOffset: DateTimeFormatter
- final def asInstanceOf[T0]: T0
- def clone(): AnyRef
- final def eq(arg0: AnyRef): Boolean
- def equals(arg0: AnyRef): Boolean
- final def getClass(): Class[_ <: AnyRef]
- def hashCode(): Int
- final def isInstanceOf[T0]: Boolean
- final def ne(arg0: AnyRef): Boolean
- final def notify(): Unit
- final def notifyAll(): Unit
- def parseModifiedDate(date: String): Option[Date]
- val standardDateParserWithoutTZ: DateTimeFormatter
- final def synchronized[T0](arg0: => T0): T0
- def toString(): String
- final def wait(arg0: Long, arg1: Int): Unit
- final def wait(arg0: Long): Unit
- final def wait(): Unit
- object Asset extends Serializable
Deprecated Value Members
- def finalize(): Unit
Inherited from AnyRef
Inherited from Any
Ungrouped
- case class Asset(name: String) extends Product with Serializable
Controller that serves static resources.
Resources are searched in the classpath.
It handles Last-Modified and ETag header automatically. If a gzipped version of a resource is found (Same resource name with the .gz suffix), it is served instead. If a digest file is available for a given asset then its contents are read and used to supply a digest value. This value will be used for serving up ETag values and for the purposes of reverse routing. For example given "a.js", if there is an "a.js.md5" file available then the latter contents will be used to determine the Etag value. The reverse router also uses the digest in order to translate any file to the form <digest>-<asset> for example "a.js" may be also found at "d41d8cd98f00b204e9800998ecf8427e-a.js". If there is no digest file found then digest values for ETags are formed by forming a sha1 digest of the last-modified time.
The default digest algorithm to search for is "md5". You can override this quite easily. For example if the SHA-1 algorithm is preferred:
You can set a custom Cache directive for a particular resource if needed. For example in your application.conf file:
You can use this controller in any application, just by declaring the appropriate route. For example:
GET /assets/\uFEFF*file controllers.Assets.at(path="/public", file)