J'ai deux Actions dans différents contrôleurs ActionA
et ActionB J'appelle ActionB
dans ActionA et je veux obtenir sa réponse (ActionB) dans ActionA est-ce possible? Comment puis-je achive cette s'il vous plaît aider voici mon codecomment obtenir la réponse de Action appelée dans un cadre Action in play
class ControllerA extends Controller{
def ActionA = Action { implicit request =>
var jsonRequest = request.body.asJson.get
val uuid = (jsonRequest \ "uuid").as[String]
log.info("in ActionA" + uuid)
val controllerB= new ControllerB
val actionB=controllerB.ActionB.apply(request)
//here i want to get the response of ActionB and return this response as the response of ActionA whether its OK or InternelServerError
Ok("i want to show the response of ActionB")
}
}
class ControllerB extends Controller{
def ActionB = Action { implicit request =>
var jsonRequest = request.body.asJson.get
val uuid = (jsonRequest \ "uuid").as[String]
log.info("in ActionB " + uuid)
try {
Ok("i am ActionB with id {}"+uuid)
} catch {
case e: Exception =>
log.error("Exception ", e)
val status = Http.Status.INTERNAL_SERVER_ERROR
InternalServerError(Json.obj("status" -> status, "msg" -> ServerResponseMessages.INTERNAL_SERVER_ERROR))
}
}
}
s'il vous plaît aider
Merci beaucoup – swaheed