Create your own action much more powerful and flexible.
object MyAction { def apply[A](bodyParser: BodyParser[A])(block: Request[A] => Result): Action[A] = Action(bodyParser) { request => // TODO : authentication, cache logics here // time it val start = ... // process val r = block(request) val end = ... // log remote address, user agent, time, etc. r } // simply override to use MyAction def apply(block: Request[AnyContent] => Result): Action[AnyContent] = this.apply(BodyParsers.parse.anyContent)(block) // simply override to use MyAction def apply(block: => Result): Action[AnyContent] = this.apply(_ => block) }
to use it in the controller just replace Action with MyAction
def index = MyAction { implicit request =>
source share