-
-
Save brikis98/5095459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.api._ | |
import play.api.mvc._ | |
object Global extends GlobalSettings { | |
def ResponseTime[A](action: Action[A]): Action[A] = Action(action.parser) { request => | |
val start = System.currentTimeMillis | |
val result = action(request) | |
println( request + " -> " + (System.currentTimeMillis - start) + " ms.") | |
result | |
} | |
override def onRouteRequest(request: RequestHeader): Option[Handler] = { | |
super.onRouteRequest(request).map { | |
case action: Action[_] => ResponseTime(action) | |
case other => other | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment