Action
is a trait (play.api.mvc.Action
). Essentially it represents this type: play.api.mvc.Request => play.api.mvc.Result
(doc1, doc2).
In your case you are using Action {...}
which is equivalent to Action(...)
and converted by compiler to Action.apply(...)
call. If you check source code you'll see the apply
method signatures defined not only on the Action
trait and it's companion object, but also in here:
/**
* Provides helpers for creating `Action` values.
*/
trait ActionBuilder[+R[_]] extends ActionFunction[Request, R]
In your case you are not taking any request and not producing any response, so essentially your Action
is a function call of a form apply(block: => Result)
where Result
is thrown away since you define return type of your function as Unit
.
Action
supports many ways you can handle its body (including Futures) so pick the right apply
method to cover your needs.
You can extend Action
if you need to since it's not a final implementation. Here is an example:
case class Logging[A](action: Action[A]) extends Action[A]