1
votes

I have been using the Play Framework for Scala and Have Run Into Some Trouble.

I am trying to Call Another Controller Method From A Controller Method. At First I tried Using The WSRequest/Response To Call the Other Controller Method's Route however The WSResponse Contained Nothing! No Cookies or Header Even though the Controller's method would return a redirect WithCookies.

Also I AM not Sure How To Just Directly call The Controller Method Since It Returns a EssentialAction, But the First Method Uses the Implicit Request ActionAsync Method Which Require's a Future[Result]. How would I Use the EssentiaLAction to Make a Future[Result]!!?

Any Ideas On How to Fix MY PRoblem? THanks!

1

1 Answers

2
votes

Based on Action composition

def a(s: String): Action[AnyContent] = Action.async {
  Future(Ok(s))
}

def b: Action[AnyContent] = Action.async {request =>
  a("from b")(request)
}