Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brikis98
Forked from guillaumebort/Global.scala
Created March 5, 2013 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brikis98/5095459 to your computer and use it in GitHub Desktop.
Save brikis98/5095459 to your computer and use it in GitHub Desktop.
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