I've got a play framework application and a problematic action. I'm trying to parse a request body using parse.form
and then have an ActionFilter
run against that parsed body.
So far I've got something like this
object ModelValidationAction extends ActionFilter[Request[MyModel]]{
def filter[A <: MyModel](request: Request[A]) = ???
}
def routePointsHere = (Action(parse.form(myModelForm)) andThen ModelValidationAction) { (request: Request[MyModel]) => ??? }
however IDEA gives me the error hint
expected Action[MyModel] => NotInferredA, actual ModelValidationAction.type
and the compiler tells me
... missing argument list for method apply in trait ActionBuilder
[error] Unapplied methods are only converted to functions when a function type is expected. [error] You can make this conversion explicit by writingapply _
orapply(_)(_)
instead ofapply
.
So I can gather that the issue is the method apply[A](bodyParser: BodyParser[A])(block: R[A] => Result): Action[A]
around the fact that that second parameter list is not getting filled, but I don't know exactly how the language behaves here.
My (completely baseless) assumption is that Action(parse.form(myModelForm))
would become Request[MyModel] => Result
and that invoking andThen
would return the same.
Any pointers as to what I'm missing? Thanks!
Action.andThen(ModelValidationAction).async(parse.json) { ??? }
. I expect it'd be very similar here too, but I'm not sure exactly how it'd map. – Hopple