2016-06-17 2 views
1

간단한 컨트롤러로 재생 프레임 워크 2.5를 시도 할 때 발생하는 오류 메시지가 당황 할 수 있습니다. 여기에 내가 뭘하는지입니다 :간단한 프레임 워크에서 Play Framework 2.5 오류가 발생했습니다.

object UserController extends Controller { 

    def login = Action.async(BodyParsers.parse.json) { request => 
    val body = request.body.validate[UserLogin] 
    // call the userService and validate the credentials 
    body.fold(
     errors => { 
     BadRequest(Json.obj("status" -> "error", "message" -> JsError.toFlatJson(errors))) 
     }, // error here 
     message => { 
     Ok("") 
     } // error here 
    ) 
    } 
} 

내가 얻을 오류 메시지가 말한다 :

"Expression of type Result does not conform to expected type _X" 
+0

나는 당신이 '비동기' – rethab

답변

1

가 나는 미래에 전화를 포장 할 필요가! 그래서 여기에 그것을하는 방법입니다!

object UserController extends Controller { 

    def login = Action.async(BodyParsers.parse.json) { request => 
    val body = request.body.validate[UserLogin] 
    // call the userService and validate the credentials 
    body.fold(
     errors => { 
     Future.successful { BadRequest(Json.obj("status" -> "error", "message" -> JsError.toFlatJson(errors))) } 
     }, // error here 
     message => { 
     Future.successful { Ok("") } 
     } // error here 
    ) 
    } 
} 
+0

당신은 어떻게 노출 수를 호출하거나 'Future.successful'의 TWE 응답 포장을 제거 할 수 있다고 생각? –

관련 문제