다른 컨트롤러에 두 개의 액션이 있습니다 ActionA
및 ActionB ActionA에서 ActionB
을 호출 중이며 ActionA에서 ActionB 응답을 받고 싶습니다. 내가이 여기에 도움을 주시기 바랍니다 achive 수있는 방법을하는 단일 JVM에서 컨트롤러를 배포하는 경우재생 프레임 워크의 작업 내에서 호출 된 작업의 응답을 얻는 방법
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))
}
}
}
이
감사합니다. – swaheed