1

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!

MrTugay
  • 21
  • 4

1 Answers1

2

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)
}
andrey.ladniy
  • 1,664
  • 1
  • 11
  • 27
  • do you also happen to know why the WSResponse was not capturing the correctly cookies/headers/or status from the second call? Everything before that works fine – MrTugay May 17 '16 at 19:30
  • I don't understand problem with cookies/headers/or status. If this answer helps you with primary question, check answered (useful) and create new question for your other problems please. – andrey.ladniy May 18 '16 at 06:11