Created
September 18, 2012 11:32
-
-
Save eamelink/3742696 to your computer and use it in GitHub Desktop.
Play 2 Scala interceptors
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
override def onRouteRequest(request: RequestHeader): Option[Handler] = { | |
super.onRouteRequest(request).map { | |
case action: Action[body] => Action[body](action.parser) { (request: Request[body]) => | |
println("Before!") | |
val result = action.apply(request) | |
result match { | |
case AsyncResult(resultPromise) => resultPromise.onRedeem { _ => | |
println("After!") | |
} | |
case otherResult => { | |
println("After!") | |
} | |
} | |
result | |
} | |
case other => other | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We should also deal with other Handler subclasses.