play.api.mvc

package play.api.mvc

Contains the Controller/Action/Result API to handle HTTP requests.

For example, a typical controller:

class HomeController @Inject() (val controllerComponents: ControllerComponents) extends BaseController {

 def index = Action {
   Ok("It works!")
 }

}

Attributes

Members list

Packages

Type members

Classlikes

abstract class AbstractController(val controllerComponents: ControllerComponents) extends BaseController

An abstract implementation of BaseController to make it slightly easier to use.

An abstract implementation of BaseController to make it slightly easier to use.

Attributes

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

Define a set of extractors allowing to pattern match on the Accept HTTP header of a request

Define a set of extractors allowing to pattern match on the Accept HTTP header of a request

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
case class Accepting(mimeType: String)

Convenient class to generate extractors checking if a given mime type matches the Accept header of a request. Example of use:

Convenient class to generate extractors checking if a given mime type matches the Accept header of a request. Example of use:

val AcceptsMp3 = Accepting("audio/mp3")

Then:

request match {
 case AcceptsMp3() => ...
}

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait Action[A] extends EssentialAction

An action is essentially a (Request[A] => Result) function that handles a request and generates a result to be sent to the client.

An action is essentially a (Request[A] => Result) function that handles a request and generates a result to be sent to the client.

For example,

val echo = Action { request =>
 Ok("Got request [" + request + "]")
}

Type parameters

A

the type of the request body

Attributes

Supertypes
trait Handler
class Object
trait Matchable
class Any
Show all
Known subtypes
class JavaAction
trait ActionBuilder[+R[_], B] extends ActionFunction[Request, R]

Provides helpers for creating Action values.

Provides helpers for creating Action values.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
object ActionBuilder

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
class ActionBuilderImpl[B](val parser: BodyParser[B])(implicit val executionContext: ExecutionContext) extends ActionBuilder[Request, B]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait ActionFilter[R[_]] extends ActionRefiner[R, R]

A simple kind of ActionRefiner which, given a request (of type R), may either immediately produce a Result (for example, an error), or continue its Action block with the same request. The critical (abstract) function is filter.

A simple kind of ActionRefiner which, given a request (of type R), may either immediately produce a Result (for example, an error), or continue its Action block with the same request. The critical (abstract) function is filter.

Attributes

Supertypes
trait ActionRefiner[R, R]
trait ActionFunction[R, R]
class Object
trait Matchable
class Any
trait ActionFunction[-R[_], +P[_]]

A builder for generic Actions that generalizes over the type of requests. An ActionFunction[R,P] may be chained onto an existing ActionBuilder[R] to produce a new ActionBuilder[P] using andThen. The critical (abstract) function is invokeBlock. Most users will want to use ActionBuilder instead.

A builder for generic Actions that generalizes over the type of requests. An ActionFunction[R,P] may be chained onto an existing ActionBuilder[R] to produce a new ActionBuilder[P] using andThen. The critical (abstract) function is invokeBlock. Most users will want to use ActionBuilder instead.

Type parameters

P

the parameter type which blocks executed by this builder take (output)

R

the type of the request on which this is invoked (input)

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
trait ActionRefiner[-R[_], +P[_]] extends ActionFunction[R, P]

A simple kind of ActionFunction which, given a request (of type R), may either immediately produce a Result (for example, an error), or call its Action block with a parameter (of type P). The critical (abstract) function is refine.

A simple kind of ActionFunction which, given a request (of type R), may either immediately produce a Result (for example, an error), or call its Action block with a parameter (of type P). The critical (abstract) function is refine.

Attributes

Supertypes
trait ActionFunction[R, P]
class Object
trait Matchable
class Any
Known subtypes
trait ActionFilter[R]
trait ActionTransformer[R, P]
trait ActionTransformer[-R[_], +P[_]] extends ActionRefiner[R, P]

A simple kind of ActionRefiner which, given a request (of type R), unconditionally transforms it to a new parameter type (P) to be passed to its Action block. The critical (abstract) function is transform.

A simple kind of ActionRefiner which, given a request (of type R), unconditionally transforms it to a new parameter type (P) to be passed to its Action block. The critical (abstract) function is transform.

Attributes

Supertypes
trait ActionRefiner[R, P]
trait ActionFunction[R, P]
class Object
trait Matchable
class Any
sealed trait AnyContent

A request body that adapts automatically according the request Content-Type.

A request body that adapts automatically according the request Content-Type.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object AnyContent

Factory object for creating an AnyContent instance. Useful for unit testing.

Factory object for creating an AnyContent instance. Useful for unit testing.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
AnyContent.type
case object AnyContentAsEmpty extends AnyContent

AnyContent - Empty request body

AnyContent - Empty request body

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait AnyContent
class Object
trait Matchable
class Any
Show all
Self type
case class AnyContentAsFormUrlEncoded(data: Map[String, Seq[String]]) extends AnyContent

AnyContent - Form url encoded body

AnyContent - Form url encoded body

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait AnyContent
class Object
trait Matchable
class Any
Show all
case class AnyContentAsJson(json: JsValue) extends AnyContent

AnyContent - Json body

AnyContent - Json body

Attributes

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

AnyContent - Multipart form data body

AnyContent - Multipart form data body

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait AnyContent
class Object
trait Matchable
class Any
Show all
case class AnyContentAsRaw(raw: RawBuffer) extends AnyContent

AnyContent - Raw body (give access to the raw data as bytes).

AnyContent - Raw body (give access to the raw data as bytes).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait AnyContent
class Object
trait Matchable
class Any
Show all
case class AnyContentAsText(txt: String) extends AnyContent

AnyContent - Text body

AnyContent - Text body

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait AnyContent
class Object
trait Matchable
class Any
Show all
case class AnyContentAsXml(xml: NodeSeq) extends AnyContent

AnyContent - XML body

AnyContent - XML body

Attributes

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

Defines utility methods to generate Action and Results types.

Defines utility methods to generate Action and Results types.

For example:

class HomeController @Inject() (val controllerComponents: ControllerComponents) extends BaseController {

 def hello(name:String) = Action { request =>
   Ok("Hello " + name)
 }

}

This is intended to provide the idiomatic Play API for actions, allowing you to use "Action" for the default action builder and "parse" to access Play's default body parsers. You may want to extend this to provide your own base controller class, or write your own version with similar code.

Attributes

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

Useful prewired mixins for controller components, assuming an available ControllerComponents.

Useful prewired mixins for controller components, assuming an available ControllerComponents.

If you want to extend your own AbstractController but want to use a different base "Action", you can mix in this trait.

Attributes

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

A body parser parses the HTTP request body content.

A body parser parses the HTTP request body content.

Type parameters

A

the body content type

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Default
Self type
BodyParser[A] & Any
object BodyParser

Helper object to construct BodyParser values.

Helper object to construct BodyParser values.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
BodyParser.type

A set of reusable body parsers and utilities that do not require configuration.

A set of reusable body parsers and utilities that do not require configuration.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
object BodyParsers

Default BodyParsers.

Default BodyParsers.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class Call(method: String, url: String, fragment: String) extends Call

Defines a Call, which describes an HTTP request and can be used to create links or fill redirect data.

Defines a Call, which describes an HTTP request and can be used to create links or fill redirect data.

These values are usually generated by the reverse router.

Value parameters

method

the request HTTP method

url

the request URL

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Call
class Object
trait Matchable
class Any
Show all
case class Codec(charset: String)(encode: String => ByteString, decode: ByteString => String)

A Codec handle the conversion of String to Byte arrays.

A Codec handle the conversion of String to Byte arrays.

Value parameters

charset

The charset to be sent to the client.

encode

The transformation function.

Attributes

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

Default Codec support.

Default Codec support.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Codec.type

The base controller components dependencies that most controllers rely on.

The base controller components dependencies that most controllers rely on.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Useful mixins for controller classes.

Useful mixins for controller classes.

If you wish to write a controller with minimal dependencies, you can mix in this trait, which includes helpers and useful constants.

 class MyController @Inject() (action: DefaultActionBuilder, parse: PlayBodyParsers) extends ControllerHelpers {
   def index = action(parse.text) {
     Ok
   }
 }

Attributes

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

Attributes

Companion
trait
Supertypes
trait Rendering
trait ContentTypes
trait HeaderNames
trait Status
trait HttpProtocol
trait Results
class Object
trait Matchable
class Any
Show all
Self type
case class Cookie(name: String, value: String, maxAge: Option[Int], path: String, domain: Option[String], secure: Boolean, httpOnly: Boolean, sameSite: Option[SameSite], partitioned: Boolean)

An HTTP cookie.

An HTTP cookie.

Value parameters

domain

the cookie domain

httpOnly

whether this cookie is HTTP only, i.e. not accessible from client-side JavaScript code

maxAge

the cookie expiration date in seconds, None for a transient cookie, or a value 0 or less to expire a cookie now

name

the cookie name

partitioned

whether the Partitioned attribute of the cookie should be set (true) or not (false) to support CHIPS (Cookies Having Independent Partitioned State)

path

the cookie path, defaulting to the root path /

sameSite

defines cookie access restriction: first-party or same-site context

secure

whether this cookie is secured, sent only for HTTPS requests

value

the cookie value

Attributes

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

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Cookie.type
trait CookieBaker[T <: AnyRef]

Trait that should be extended by the Cookie helpers.

Trait that should be extended by the Cookie helpers.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type

This trait encodes and decodes data to a string used as cookie value.

This trait encodes and decodes data to a string used as cookie value.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Logic for encoding and decoding Cookie and Set-Cookie headers.

Logic for encoding and decoding Cookie and Set-Cookie headers.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

Utilities for merging individual cookie values in HTTP cookie headers.

Utilities for merging individual cookie values in HTTP cookie headers.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait Cookies extends Iterable[Cookie]

The HTTP cookies set.

The HTTP cookies set.

Attributes

Companion
object
Supertypes
trait Iterable[Cookie]
class Object
trait Matchable
class Any
Show all
object Cookies extends CookieHeaderEncoding

Helper utilities to encode Cookies.

Helper utilities to encode Cookies.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Cookies.type
class CookiesModule extends SimpleModule

A cookie module that uses JWT as the cookie encoding, falling back to URL encoding.

A cookie module that uses JWT as the cookie encoding, falling back to URL encoding.

Attributes

Supertypes
class SimpleModule
class Module
class Object
trait Matchable
class Any

A trait representing the default action builder used by Play's controllers.

A trait representing the default action builder used by Play's controllers.

This trait is used for binding, since some dependency injection frameworks doesn't deal with types very well.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Show all
case class DefaultControllerComponents(actionBuilder: DefaultActionBuilder, parsers: PlayBodyParsers, messagesApi: MessagesApi, langs: Langs, fileMimeTypes: FileMimeTypes, executionContext: ExecutionContext) extends ControllerComponents

Attributes

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

The default implementation of CookieHeaders.

The default implementation of CookieHeaders.

Attributes

Supertypes
class Object
trait Matchable
class Any
class DefaultFlashCookieBaker(val config: FlashConfiguration, val secretConfiguration: SecretConfiguration, val cookieSigner: CookieSigner) extends FlashCookieBaker, FallbackCookieDataCodec

Attributes

Supertypes
class Object
trait Matchable
class Any
Show all
case class DefaultJWTCookieDataCodec(secretConfiguration: SecretConfiguration, jwtConfiguration: JWTConfiguration) extends JWTCookieDataCodec

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class DefaultMessagesControllerComponents(messagesActionBuilder: MessagesActionBuilder, actionBuilder: DefaultActionBuilder, parsers: PlayBodyParsers, messagesApi: MessagesApi, langs: Langs, fileMimeTypes: FileMimeTypes, executionContext: ExecutionContext) extends MessagesControllerComponents

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
class DefaultPlayBodyParsers(val config: ParserConfiguration, val errorHandler: HttpErrorHandler, val materializer: Materializer, val temporaryFileCreator: TemporaryFileCreator) extends PlayBodyParsers

Attributes

Supertypes
class Object
trait Matchable
class Any

A session cookie that reads in both signed and JWT cookies, and writes out JWT cookies.

A session cookie that reads in both signed and JWT cookies, and writes out JWT cookies.

Attributes

Supertypes
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class DiscardingCookie(name: String, path: String, domain: Option[String], secure: Boolean, sameSite: Option[SameSite], partitioned: Boolean)

A cookie to be discarded. This contains only the data necessary for discarding a cookie.

A cookie to be discarded. This contains only the data necessary for discarding a cookie.

Value parameters

domain

the cookie domain

name

the name of the cookie to discard

partitioned

whether this cookie is partitioned

path

the path of the cookie, defaults to the root path

sameSite

the SameSite attribute of the cookie

secure

whether this cookie is secured

Attributes

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

An EssentialAction underlies every Action. Given a RequestHeader, an EssentialAction consumes the request body (an ByteString) and returns a Result.

An EssentialAction underlies every Action. Given a RequestHeader, an EssentialAction consumes the request body (an ByteString) and returns a Result.

An EssentialAction is a Handler, which means it is one of the objects that Play uses to handle requests.

Attributes

Companion
object
Supertypes
trait Handler
class Object
trait Matchable
class Any
Known subtypes
trait Action[A]
class JavaAction
Self type

Helper for creating EssentialActions.

Helper for creating EssentialActions.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Filter

A trait that identifies the cookie encoding and uses the appropriate codec, for upgrading from a signed cookie encoding to a JWT cookie encoding.

A trait that identifies the cookie encoding and uses the appropriate codec, for upgrading from a signed cookie encoding to a JWT cookie encoding.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Filter extends EssentialFilter

Implement this interface if you want to add a Filter to your application

Implement this interface if you want to add a Filter to your application

object AccessLog extends Filter {
 override def apply(next: RequestHeader => Future[Result])(request: RequestHeader): Future[Result] = {
   val result = next(request)
   result.map { r => play.Logger.info(request + "\n\t => " + r); r }
 }
}

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Self type
object Filter

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Filter.type
object FilterChain

Compose the action and the Filters to create a new Action

Compose the action and the Filters to create a new Action

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object Filters

Compose the action and the Filters to create a new Action

Compose the action and the Filters to create a new Action

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Filters.type
case class Flash(data: Map[String, String])

HTTP Flash scope.

HTTP Flash scope.

Flash data are encoded into an HTTP cookie, and can only contain simple String values.

Attributes

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

Attributes

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

Helper utilities to manage the Flash cookie.

Helper utilities to manage the Flash cookie.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Handler

An Handler handles a request. Play understands several types of handlers, for example EssentialActions and WebSockets.

An Handler handles a request. Play understands several types of handlers, for example EssentialActions and WebSockets.

The Handler used to handle the request is controlled by GlobalSettings's onRequestReceived method. The default implementation of onRequestReceived delegates to onRouteRequest which calls the default Router.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Action[A]
class JavaAction
trait Stage
trait WebSocket
trait JavaHandler
Show all
object Handler

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Handler.type
class Headers(var _headers: Seq[(String, String)])

The HTTP headers set.

The HTTP headers set.

Value parameters

_headers

The sequence of values. This value is protected and mutable since subclasses might initially set it to a null value and then initialize it lazily.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object Headers

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Headers.type

A variation of BaseController that gets its components via method injection.

A variation of BaseController that gets its components via method injection.

Attributes

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

JWT cookie encoding and decoding functionality

JWT cookie encoding and decoding functionality

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Transform a value to a Javascript literal.

Transform a value to a Javascript literal.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Default JavaScript literals converters.

Default JavaScript literals converters.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

A cookie module that uses the urlencoded cookie encoding.

A cookie module that uses the urlencoded cookie encoding.

Attributes

Supertypes
class SimpleModule
class Module
class Object
trait Matchable
class Any
class LegacyFlashCookieBaker(val config: FlashConfiguration, val secretConfiguration: SecretConfiguration, val cookieSigner: CookieSigner) extends FlashCookieBaker, UrlEncodedCookieDataCodec

Attributes

Supertypes
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Results

A session cookie baker that signs the session cookie in the Play 2.5.x style.

A session cookie baker that signs the session cookie in the Play 2.5.x style.

Value parameters

config

session configuration

cookieSigner

the cookie signer, typically HMAC-SHA1

Attributes

Supertypes
class Object
trait Matchable
class Any
Show all
case class MaxSizeExceeded(length: Long) extends MaxSizeStatus

Signal a max content size exceeded.

Signal a max content size exceeded.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case object MaxSizeNotExceeded extends MaxSizeStatus

Signal max size is not exceeded.

Signal max size is not exceeded.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
sealed trait MaxSizeStatus

The status of a max size flow.

The status of a max size flow.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
abstract class MessagesAbstractController(val controllerComponents: MessagesControllerComponents) extends MessagesBaseController

An abstract controller class that returns a MessagesRequest as the default Action.

An abstract controller class that returns a MessagesRequest as the default Action.

An abstract implementation of MessagesBaseController to make it slightly easier to use.

 class MyController @Inject()(cc: MessagesControllerComponents) extends MessagesAbstractController(cc) {
   def index = Action { implicit request: MessagesRequest[AnyContent] =>
     Ok(views.html.formTemplate(form)) // twirl template with form builders
   }
 }

Attributes

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

This trait is an ActionBuilder that provides a MessagesRequest to the block:

This trait is an ActionBuilder that provides a MessagesRequest to the block:

class MyController @Inject()(
 messagesAction: MessagesActionBuilder,
 cc: ControllerComponents
) extends AbstractController(cc) {
 def index = messagesAction { implicit request: MessagesRequest[AnyContent] =>
    Ok(views.html.formTemplate(form)) // twirl template with form builders
 }
}

This is useful when you don't want to have to add play.api.i18n.I18nSupport to a controller for form processing.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class MessagesActionBuilderImpl[B](val parser: BodyParser[B], messagesApi: MessagesApi)(implicit val executionContext: ExecutionContext) extends ActionBuilder[MessagesRequest, B]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

A base controller that returns a MessagesRequest as the base Action.

A base controller that returns a MessagesRequest as the base Action.

Attributes

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

Controller components with a MessagesActionBuilder.

Controller components with a MessagesActionBuilder.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

A variation of MessagesAbstractController that gets its components via method injection.

A variation of MessagesAbstractController that gets its components via method injection.

Attributes

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

This class is a wrapped Request that is "i18n-aware" and can return the preferred messages associated with the request.

This class is a wrapped Request that is "i18n-aware" and can return the preferred messages associated with the request.

Type parameters

A

the body type of the request

Value parameters

messagesApi

the injected messagesApi

request

the original request

Attributes

Supertypes
class WrappedRequest[A]
trait Request[A]
class Object
trait Matchable
class Any
Show all

This trait is a RequestHeader that can provide a play.api.i18n.Messages instance.

This trait is a RequestHeader that can provide a play.api.i18n.Messages instance.

This is very useful with when used for forms processing, as the form helpers defined in views.helper (e.g. inputText.scala.html) take a MessagesProvider.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class MessagesRequest[A]
case class MultipartFormData[A](dataParts: Map[String, Seq[String]], files: Seq[FilePart[A]], badParts: Seq[BadPart])

Multipart form data body.

Multipart form data body.

Attributes

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

Defines parts handled by Multipart form data.

Defines parts handled by Multipart form data.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
trait PathBindable[A]

Binder for URL path parameters.

Binder for URL path parameters.

You can provide an implementation of PathBindable[A] for any type A you want to be able to bind directly from the request path.

For example, given this class definition:

 case class User(id: Int, name: String, age: Int)

You can define a binder retrieving a User instance from its id, useable like the following:

 // In your routes:
 // GET  /show/:user      controllers.Application.show(user)
 // For example: /show/42

 class HomeController @Inject() (val controllerComponents: ControllerComponents) extends BaseController {
   def show(user: User) = Action {
     ...
   }
 }

The definition of binder can look like the following:

 object User {
   implicit def pathBinder(implicit intBinder: PathBindable[Int]) = new PathBindable[User] {
     override def bind(key: String, value: String): Either[String, User] = {
       for {
         id <- intBinder.bind(key, value).right
         user <- User.findById(id).toRight("User not found").right
       } yield user
     }
     override def unbind(key: String, user: User): String = {
       intBinder.unbind(key, user.id)
     }
   }
 }

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Parsing[A]
object bindableFloat
object bindableInt
object bindableLong
object bindableShort
object bindableUUID
object bindableChar
Show all
Self type

Default binders for URL path part.

Default binders for URL path part.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object PathBindable

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Body parsers officially supported by Play (i.e. built-in to Play)

Body parsers officially supported by Play (i.e. built-in to Play)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

This trait is a play.api.i18n.MessagesProvider that can be applied to a RequestHeader, and uses messagesApi.preferred(requestHeader) to return the messages.

This trait is a play.api.i18n.MessagesProvider that can be applied to a RequestHeader, and uses messagesApi.preferred(requestHeader) to return the messages.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class MessagesRequest[A]
Self type

Binder for query string parameters.

Binder for query string parameters.

You can provide an implementation of QueryStringBindable[A] for any type A you want to be able to bind directly from the request query string.

For example, if you have the following type to encode pagination:

 /**
  * @param index Current page index
  * @param size Number of items in a page
  */
 case class Pager(index: Int, size: Int)

Play will create a Pager(5, 42) value from a query string looking like /foo?p.index=5&p.size=42 if you define an instance of QueryStringBindable[Pager] available in the implicit scope.

For example:

 object Pager {
   implicit def queryStringBinder(implicit intBinder: QueryStringBindable[Int]) = new QueryStringBindable[Pager] {
     override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, Pager]] = {
       for {
         index <- intBinder.bind(key + ".index", params)
         size <- intBinder.bind(key + ".size", params)
       } yield {
         (index, size) match {
           case (Right(index), Right(size)) => Right(Pager(index, size))
           case _ => Left("Unable to bind a Pager")
         }
       }
     }
     override def unbind(key: String, pager: Pager): String = {
       intBinder.unbind(key + ".index", pager.index) + "&" + intBinder.unbind(key + ".size", pager.size)
     }
   }
 }

To use it in a route, just write a type annotation aside the parameter you want to bind:

 GET  /foo        controllers.foo(p: Pager)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Parsing[A]
object bindableFloat
object bindableInt
object bindableLong
object bindableShort
object bindableUUID
object bindableChar
Show all
Self type

Default binders for Query String

Default binders for Query String

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object RangeResult

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
case class RawBuffer(memoryThreshold: Long, temporaryFileCreator: TemporaryFileCreator, initialData: ByteString)

Handle the request body a raw bytes data.

Handle the request body a raw bytes data.

Value parameters

initialData

the initial data, ByteString.empty by default.

memoryThreshold

If the content size is bigger than this limit, the content is stored as file.

temporaryFileCreator

the temporary file creator to store the content as file.

Attributes

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

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Request[+A] extends RequestHeader

The complete HTTP request.

The complete HTTP request.

Type parameters

A

the body content type.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class WrappedRequest[A]
class MessagesRequest[A]
class AuthenticatedRequest[A, U]
Self type
Request[A]
object Request

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Request.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

The HTTP request header. Note that it doesn't contain the request body yet.

The HTTP request header. Note that it doesn't contain the request body yet.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
object RequestHeader

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type

Useful mixin for methods that do implicit transformations of a request

Useful mixin for methods that do implicit transformations of a request

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
final class ResponseHeader(val status: Int, _headers: Map[String, String], val reasonPhrase: Option[String])

A simple HTTP response header, used for standard responses.

A simple HTTP response header, used for standard responses.

Value parameters

_headers

the HTTP headers

reasonPhrase

the human-readable description of status, e.g. "Ok"; if None, the default phrase for the status will be used

status

the response status, e.g. 200

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
object Result

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Result.type
case class Result(header: ResponseHeader, body: HttpEntity, newSession: Option[Session], newFlash: Option[Flash], newCookies: Seq[Cookie], attrs: TypedMap)

A simple result, which defines the response header and a body ready to send to the client.

A simple result, which defines the response header and a body ready to send to the client.

Value parameters

body

the response body

header

the response header, which contains status code and HTTP headers

Attributes

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

Helper utilities to generate results.

Helper utilities to generate results.

Attributes

Companion
trait
Supertypes
trait Results
class Object
trait Matchable
class Any
Self type
Results.type
trait Results

Helper utilities to generate results.

Helper utilities to generate results.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Security

Helpers to create secure actions.

Helpers to create secure actions.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Security.type
case class Session(data: Map[String, String])

HTTP Session.

HTTP Session.

Session data are encoded into an HTTP cookie, and can only contain simple String values.

Attributes

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

Attributes

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

Helper utilities to manage the Session cookie.

Helper utilities to manage the Session cookie.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

This trait writes out cookies as url encoded safe text format, optionally prefixed with a signed code.

This trait writes out cookies as url encoded safe text format, optionally prefixed with a signed code.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait WebSocket extends Handler

A WebSocket handler.

A WebSocket handler.

Attributes

Companion
object
Supertypes
trait Handler
class Object
trait Matchable
class Any
object WebSocket

Helper utilities to generate WebSocket results.

Helper utilities to generate WebSocket results.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
WebSocket.type
class WrappedRequest[+A](request: Request[A]) extends Request[A]

Wrap an existing request. Useful to extend a request.

Wrap an existing request. Useful to extend a request.

If you need to add extra values to a request, you could consider using request attributes instead. See the attr, withAttr, etc methods.

Attributes

Supertypes
trait Request[A]
class Object
trait Matchable
class Any
Known subtypes
class MessagesRequest[A]
class AuthenticatedRequest[A, U]