Convenient extractor allowing to apply two extractors.
Convenient extractor allowing to apply two extractors. Example of use:
request match { case Accepts.Json() & Accepts.Html() => "This request accepts both JSON and HTML" }
Generates a ‘202 ACCEPTED’ result.
Generates a ‘202 ACCEPTED’ result.
Common extractors to check if a request accepts JSON, Html, etc.
Common extractors to check if a request accepts JSON, Html, etc. Example of use:
request match { case Accepts.Json() => Ok(toJson(value)) case _ => Ok(views.html.show(value)) }
Content-Type of binary data.
Content-Type of binary data.
Generates a ‘502 BAD_GATEWAY’ result.
Generates a ‘502 BAD_GATEWAY’ result.
Generates a ‘400 BAD_REQUEST’ result.
Generates a ‘400 BAD_REQUEST’ result.
Content-Type of application cache.
Content-Type of application cache.
Content-Type of css.
Content-Type of css.
Generates a ‘409 CONFLICT’ result.
Generates a ‘409 CONFLICT’ result.
Generates a ‘100 Continue’ result.
Generates a ‘100 Continue’ result.
Generates a ‘201 CREATED’ result.
Generates a ‘201 CREATED’ result.
Content-Type of server sent events.
Content-Type of server sent events.
Generates a ‘413 REQUEST_ENTITY_TOO_LARGE’ result.
Generates a ‘413 REQUEST_ENTITY_TOO_LARGE’ result.
Generates a ‘417 EXPECTATION_FAILED’ result.
Generates a ‘417 EXPECTATION_FAILED’ result.
Content-Type of form-urlencoded.
Content-Type of form-urlencoded. This content type does not define a charset parameter.
Generates a ‘424 FAILED_DEPENDENCY’ result.
Generates a ‘424 FAILED_DEPENDENCY’ result.
Generates a ‘403 FORBIDDEN’ result.
Generates a ‘403 FORBIDDEN’ result.
Generates a ‘302 FOUND’ simple result.
Generates a ‘504 GATEWAY_TIMEOUT’ result.
Generates a ‘504 GATEWAY_TIMEOUT’ result.
Generates a ‘410 GONE’ result.
Generates a ‘410 GONE’ result.
Content-Type of html.
Content-Type of html.
Generates a ‘505 HTTP_VERSION_NOT_SUPPORTED’ result.
Generates a ‘505 HTTP_VERSION_NOT_SUPPORTED’ result.
Generates a ‘418 IM_A_TEAPOT’ result.
Generates a ‘418 IM_A_TEAPOT’ result.
Generates a ‘507 INSUFFICIENT_STORAGE’ result.
Generates a ‘507 INSUFFICIENT_STORAGE’ result.
Generates a ‘500 INTERNAL_SERVER_ERROR’ result.
Generates a ‘500 INTERNAL_SERVER_ERROR’ result.
Content-Type of javascript.
Content-Type of javascript.
Content-Type of json.
Content-Type of json. This content type does not define a charset parameter.
Generates a ‘423 LOCKED’ result.
Generates a ‘423 LOCKED’ result.
Generates a ‘405 METHOD_NOT_ALLOWED’ result.
Generates a ‘405 METHOD_NOT_ALLOWED’ result.
Generates a ‘301 MOVED_PERMANENTLY’ simple result.
Generates a ‘301 MOVED_PERMANENTLY’ simple result.
the URL to redirect to
Generates a ‘207 MULTI_STATUS’ result.
Generates a ‘207 MULTI_STATUS’ result.
Generates a ‘204 NO_CONTENT’ result.
Generates a ‘204 NO_CONTENT’ result.
Generates a ‘203 NON_AUTHORITATIVE_INFORMATION’ result.
Generates a ‘203 NON_AUTHORITATIVE_INFORMATION’ result.
Generates a ‘406 NOT_ACCEPTABLE’ result.
Generates a ‘406 NOT_ACCEPTABLE’ result.
Generates a ‘404 NOT_FOUND’ result.
Generates a ‘404 NOT_FOUND’ result.
Generates a ‘501 NOT_IMPLEMENTED’ result.
Generates a ‘501 NOT_IMPLEMENTED’ result.
Generates a ‘304 NOT_MODIFIED’ result.
Generates a ‘304 NOT_MODIFIED’ result.
Generates a ‘200 OK’ result.
Generates a ‘200 OK’ result.
Generates a ‘206 PARTIAL_CONTENT’ result.
Generates a ‘206 PARTIAL_CONTENT’ result.
Generates a ‘402 PAYMENT_REQUIRED’ result.
Generates a ‘402 PAYMENT_REQUIRED’ result.
Generates a ‘308 PERMANENT_REDIRECT’ simple result.
Generates a ‘308 PERMANENT_REDIRECT’ simple result.
the URL to redirect to
Generates a ‘412 PRECONDITION_FAILED’ result.
Generates a ‘412 PRECONDITION_FAILED’ result.
Generates a redirect simple result.
Generates a redirect simple result.
Call defining the URL to redirect to, which typically comes from the reverse router
HTTP status for redirect, such as SEE_OTHER, MOVED_TEMPORARILY or MOVED_PERMANENTLY
Generates a redirect simple result.
Generates a redirect simple result.
Call defining the URL to redirect to, which typically comes from the reverse router
Generates a redirect simple result.
Generates a redirect simple result.
the URL to redirect to
queryString parameters to add to the queryString
HTTP status for redirect, such as SEE_OTHER, MOVED_TEMPORARILY or MOVED_PERMANENTLY
Generates a redirect simple result.
Generates a redirect simple result.
the URL to redirect to
HTTP status
Generates a ‘408 REQUEST_TIMEOUT’ result.
Generates a ‘408 REQUEST_TIMEOUT’ result.
Generates a ‘205 RESET_CONTENT’ result.
Generates a ‘205 RESET_CONTENT’ result.
Generates a ‘303 SEE_OTHER’ simple result.
Generates a ‘503 SERVICE_UNAVAILABLE’ result.
Generates a ‘503 SERVICE_UNAVAILABLE’ result.
Generates a simple result.
Generates a ‘101 Switching Protocols’ result.
Generates a ‘101 Switching Protocols’ result.
Content-Type of text.
Content-Type of text.
Generates a ‘307 TEMPORARY_REDIRECT’ simple result.
Generates a ‘307 TEMPORARY_REDIRECT’ simple result.
the URL to redirect to
Generates a ‘429 TOO_MANY_REQUESTS’ result.
Generates a ‘429 TOO_MANY_REQUESTS’ result.
Generates a ‘401 UNAUTHORIZED’ result.
Generates a ‘401 UNAUTHORIZED’ result.
Generates a ‘422 UNPROCESSABLE_ENTITY’ result.
Generates a ‘422 UNPROCESSABLE_ENTITY’ result.
Generates a ‘415 UNSUPPORTED_MEDIA_TYPE’ result.
Generates a ‘415 UNSUPPORTED_MEDIA_TYPE’ result.
Generates a ‘414 REQUEST_URI_TOO_LONG’ result.
Generates a ‘414 REQUEST_URI_TOO_LONG’ result.
Content-Type of xhtml.
Content-Type of xhtml.
Content-Type of xml.
Content-Type of xml.
Retrieve the flash scope implicitly from the request.
Retrieve the flash scope implicitly from the request.
For example:
def index(name:String) = Action { implicit request => val message = request2flash("message") Ok("Got " + message) }
Retrieves the session implicitly from the request.
Retrieves the session implicitly from the request.
For example:
def index(name:String) = Action { implicit request => val username = request2session("username") Ok("Hello " + username) }
the codec
charset appended to mimeType
(Since version 2.6.0) Use TOO_MANY_REQUESTS instead
Generates a ‘429 TOO_MANY_REQUEST’ result.
Generates a ‘429 TOO_MANY_REQUEST’ result.
(Since version 2.6.0) Use TooManyRequests instead
Generates an Action
that serves a static resource.
Generates an Action
that serves a static resource.
the root folder for searching the static resource files, such as "/public"
. Not URL encoded.
the file part extracted from the URL. May be URL encoded (note that %2F decodes to literal /).
if true then an aggressive set of caching directives will be used. Defaults to false.
(Since version 2.6.0) Inject Assets and use Assets#at
Generates an Action
that serves a static resource, using the base asset path from configuration.
Generates an Action
that serves a static resource, using the base asset path from configuration.
(Since version 2.6.0) Inject Assets and use Assets#at
Retrieve the language implicitly from the request.
Retrieve the language implicitly from the request.
For example:
def index(name:String) = Action { implicit request => val lang: Lang = request2lang Ok("Got " + lang) }
(Since version 2.6.0) See https://www.playframework.com/documentation/2.6.x/MessagesMigration26
Generates an Action
that serves a versioned static resource.
Generates an Action
that serves a versioned static resource.
(Since version 2.6.0) Inject Assets and use Assets#versioned
Generates an Action
that serves a versioned static resource, using the base asset path from configuration.
Generates an Action
that serves a versioned static resource, using the base asset path from configuration.
(Since version 2.6.0) Inject Assets and use Assets#versioned
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/*file controllers.Assets.at(path="/public", file)