daily pastebin goal
5%
SHARE
TWEET

Untitled

a guest Oct 19th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import play.api._
  2. import play.api.mvc._
  3.  
  4. object Global extends GlobalSettings {
  5.  
  6.     def ResponseTime[A](action: Action[A]): Action[A] = Action(action.parser) { request =>
  7.         val start = System.currentTimeMillis
  8.         val result = action(request)
  9.         println( request + " -> " + (System.currentTimeMillis - start) + " ms.")
  10.         result
  11.     }
  12.  
  13.     override def onRouteRequest(request: RequestHeader): Option[Handler] = {
  14.         super.onRouteRequest(request).map {
  15.             case action: Action[_] => ResponseTime(action)
  16.             case other => other
  17.         }
  18.     }
  19.  
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top