In the Java flavor of Play 2, there is GlobalSettings.onRequest, which can be used to intercept all incoming requests to controllers. But in the Scala equivalent, there is no onRequest handler.
I suspect this is because the Action delegation logic needed in Java isn't required in Scala, but it's rather annoying because I want to run some code on every incoming controller request.
Does anyone know how to intercept all controller requests in a Scala + Play 2 app?
override def onRouteRequest (request: RequestHeader): Option[Handler]
in your Global object might be the answer you're looking for.
From the 2.0.4 api, it's called when an HTTP request has been received.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With