case class ResetPasswordJsonValidation (id : String ,email : String)
object ResetPasswordJsonValidation {
implicit val resetPasswordRead : Reads[ResetPasswordJsonValidation]= (
(JsPath \ "email").read(email) and
(JsPath \ "id").read(id))
(ResetPasswordJsonValidation.apply _)
}
def resetPassword = Action {
request =>
request.body.asJson.get.validate[ResetPasswordJsonValidation].fold(
resetPassword =>
{
log.info("id is {}" ,resetPassword.id)
log.info("email id is {}" ,resetPassword.email)
}
)
}
路径文件中的
POST /direct-user/reset-password controllers.DirectUserController.resetPassword
这是我用来点击这条路线的卷曲文件
#!/bin/bash
contentType="Content-type: application/json";
data='{ "id" : "54d3732d-d728-40d3-ae63-b18ab6be8e70" ,
"email":"bob@example.com"}';
echo " "
echo "------------------ Sending Data ------------------"
echo " "
echo "Content-Type : " $contentType
echo "Data : " $data
echo " "
echo "------------------ Response ------------------"
echo " "
echo " "
curl --include --request POST --header "Content-type: application/json" --data "$data" http://localhost:9000//direct-user/reset-password
现在我想用代码执行此操作意味着我有一个操作A
,其中我需要重定向到resetPassword
操作我不知道该怎么做
请帮帮我
def A = Action {
var email:String="bob@example.com"
var id:String="54d3732d-d728-40d3-ae63-b18ab6be8e70"
Redirect(routes.DirectUserController.resetPassword())//how can i send email and id parameter to resetPassword as its getting from curl file
}
请帮助
答案 0 :(得分:0)
您可以直接调用该方法而不是通过路径对象
来代替重定向返回directController.resetPassword()
因为上下文对象(Request,Response,Session是该线程的本地对象,所以你可以从请求对象中获取这些参数)