Created
February 18, 2016 18:22
-
-
Save cb372/68cb049a05c2aa050f2c to your computer and use it in GitHub Desktop.
This file contains hidden or 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.mvc.Security | |
object AuthAction extends Security.AuthenticatedBuilder[User](...) | |
type AuthReq = Security.AuthenticatedRequest[_, User] | |
object AuditLogAction extends ActionFunction[AuthReq, AuthReq] { | |
def invokeBlock[A](request: AuthReq[A], block: AuthReq[A] => Future[Result]): Future[Result] = { | |
/* | |
* 本当はPOSTの場合、request.body.asFormUrlEncoded も出力したいけど、 | |
* AnyContent でなく A しか持ってない。 | |
* ジェネリクスを無くして A を AnyContent に固定したい。 | |
*/ | |
println(s"User: ${request.user.email}, path: ${request.path}, method: ${request.method}") | |
block(request) | |
} | |
} | |
object MyCtlr extends Controller { | |
def authPage = (AuthAction andThen AuditLogAction){ implicit request => | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would the following work?