controllers

package controllers

Members list

Type members

Classlikes

case class AssetEncoding(acceptEncoding: String, extension: String)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object AssetEncoding

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object Assets

Controller that serves static resources.

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:

"play.assets.digest.algorithm" = "sha1"

You can set a custom Cache directive for a particular resource if needed. For example in your application.conf file:

"play.assets.cache./public/images/logo.png" = "max-age=3600"

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)

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Assets.type
class Assets(errorHandler: HttpErrorHandler, meta: AssetsMetadata, env: Environment) extends AssetsBuilder

Attributes

Companion
object
Supertypes
trait Rendering
trait ContentTypes
trait HeaderNames
trait Status
trait HttpProtocol
trait Results
class Object
trait Matchable
class Any
Show all
class AssetsBuilder(errorHandler: HttpErrorHandler, meta: AssetsMetadata, env: Environment) extends ControllerHelpers

Attributes

Supertypes
trait Rendering
trait ContentTypes
trait HeaderNames
trait Status
trait HttpProtocol
trait Results
class Object
trait Matchable
class Any
Show all
Known subtypes
class Assets

Attributes

Supertypes
class Object
trait Matchable
class Any
case class AssetsConfiguration(path: String, urlPrefix: String, defaultCharSet: String, enableCaching: Boolean, enableCacheControl: Boolean, configuredCacheControl: Map[String, Option[String]], defaultCacheControl: String, aggressiveCacheControl: String, digestAlgorithm: String, checkForMinified: Boolean, textContentTypes: Set[String], encodings: Seq[AssetEncoding])

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait AssetsFinder

Can be used to find assets according to configured base path and URL base.

Can be used to find assets according to configured base path and URL base.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
class AssetsFinderProvider(assetsMetadata: AssetsMetadata) extends Provider[AssetsFinder]

Attributes

Supertypes
class Object
trait Matchable
class Any

INTERNAL API: Retains metadata for assets that can be readily cached.

INTERNAL API: Retains metadata for assets that can be readily cached.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

A provider for AssetsMetadata that sets up necessary static state for reverse routing. The PathBindable for assets does additional "magic" using statics so routes like routes.Assets.versioned("foo.js") will find the minified and digested version of that asset.

A provider for AssetsMetadata that sets up necessary static state for reverse routing. The PathBindable for assets does additional "magic" using statics so routes like routes.Assets.versioned("foo.js") will find the minified and digested version of that asset.

It is also possible to avoid this provider and simply inject AssetsFinder. Then you can call AssetsFinder.path to get the final path of an asset according to the path and url prefix in configuration.

Attributes

Supertypes
class Object
trait Matchable
class Any
class AssetsModule extends Module

Attributes

Supertypes
class Module
class Object
trait Matchable
class Any
class Default() extends ControllerHelpers

Default actions ready to use as is from your routes file.

Default actions ready to use as is from your routes file.

Example:

GET   /google          controllers.Default.redirect(to = "http://www.google.com")
GET   /favicon.ico     controllers.Default.notFound
GET   /admin           controllers.Default.todo
GET   /xxx             controllers.Default.error

Attributes

Supertypes
trait Rendering
trait ContentTypes
trait HeaderNames
trait Status
trait HttpProtocol
trait Results
class Object
trait Matchable
class Any
Show all
class DefaultAssetsMetadata(config: AssetsConfiguration, resource: String => Option[URL], fileMimeTypes: FileMimeTypes) extends AssetsMetadata

Default implementation of AssetsMetadata.

Default implementation of AssetsMetadata.

If your application uses reverse routing with assets or the Assets static object, you should use the AssetsMetadataProvider to set up needed statics.

Attributes

Supertypes
class Object
trait Matchable
class Any

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Execution.type
class ExternalAssets(environment: Environment)(implicit ec: ExecutionContext, fileMimeTypes: FileMimeTypes) extends ControllerHelpers

Controller that serves static resources from an external folder. It useful in development mode if you want to serve static assets that shouldn't be part of the build process.

Controller that serves static resources from an external folder. It useful in development mode if you want to serve static assets that shouldn't be part of the build process.

Note that this controller IS NOT intended to be used in production mode and can lead to security issues. Therefore it is automatically disabled in production mode.

All assets are served with max-age=3600 cache directive.

You can use this controller in any application, just by declaring the appropriate route. For example:

GET     /assets/\uFEFF*file               controllers.ExternalAssets.at(path="/home/peter/myplayapp/external", file)
GET     /assets/\uFEFF*file               controllers.ExternalAssets.at(path="C:\external", file)
GET     /assets/\uFEFF*file               controllers.ExternalAssets.at(path="relativeToYourApp", file)

Attributes

Supertypes
trait Rendering
trait ContentTypes
trait HeaderNames
trait Status
trait HttpProtocol
trait Results
class Object
trait Matchable
class Any
Show all