Skip to content

Instantly share code, notes, and snippets.

@eamelink
Created September 18, 2012 11:32
Show Gist options
  • Select an option

  • Save eamelink/3742696 to your computer and use it in GitHub Desktop.

Select an option

Save eamelink/3742696 to your computer and use it in GitHub Desktop.
Play 2 Scala interceptors
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
}
}
@eamelink

Copy link
Copy Markdown
Author

We should also deal with other Handler subclasses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment