I have a Play Application that extends Controller.
Before Play 2.5, I used to be able to do the following, per @Jus12's answer to another SO question:
import play.api.test._
def getStringFromAction(action: Action[AnyContent]): String = {
val request = new FakeRequest("fakeMethod", "fakeUrl", new FakeHeaders, "fakeBody")
val result = action.apply(request).run
import scala.concurrent.duration._
Helpers.contentAsString(result)(1000 millis)
}
But after upgrading to Play 2.5, the above code no longer compiles.
At the line:
val result = action.apply(request).run
the errors are:
could not find implicit value for parameter materializer: akka.stream.Materializer
not enough arguments for method run: (implicit materializer: akka.stream.Materializer)scala.concurrent.Future[play.api.mvc.Result].
Unspecified value parameter materializer.
I'm trying to figure out how to get this working.
I have a GET action that works fine. It returns an Action[AnyContent].
I'm having trouble with the POST action. The POST action is an Action(parse.json) that returns an Action[JsValue]. I call the GET action, which already knows how to get a computed JSON answer from a separate JAR, I get an Action[AnyContent] from the GET action, but now I need to get the String out of the result body so I can pass it back via Ok(stringValue).