Doing a Redirect() always does a GET request, but the route im trying to redirect to is a POST route. It must also preserve the request data
i need to audit and log some things, then redirect the usual flow
I can see where you are going with this, but I would suggest that Action Composition would be a better approach. That way, you can have a reusable, testable, focused piece of code that just does your auditing and logging.
For example: (completely untested):
import play.api.mvc._
object AuditAction extends ActionBuilder[Request] {
def invokeBlock[A](request: Request[A], block: (Request[A]) => Future[Result]) = {
Logger.info("Action is being audited")
YourAuditingLoggerHere.logAudit(request)
block(request)
}
}
And in your controller:
def submitAuditiableThing = AuditAction { implicit request =>
YourBusinessLogicHere()
Ok(views.html.success)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.