Defining an Action for a request is merely the act of using the Action helper object, which is defined as follows:
object Action extends ActionBuilder[Request] { def invokeBlock[A](request: Request[A], block: (Request[A]) => Future[Result]) = block(request) }
The code which we write within an action block goes on to be the invokeBlock
method. This method is inherited from ActionBuilder
. This is a trait that provides helper methods to generate an Action. All the different ways in which we define an Action, such as async, synchronous, with or without specifying a parser, and so on are declared in ActionBuilder
.
We can also define our custom Actions by extending ActionBuilder
and defining a custom invoke block.