我已经创建了一个SIRD
路由器
class UserRouter @Inject()(controller:UserController) extends SimpleRouter {
override def routes:Routes = {
case GET (p"/signup/$token") =>{ //corresponds to email verification from user after sign up. This was the URL which the server had sent
println("add user request with token"); //TODOM - print token
controller.verifyUser(token); //
}
}
}
它被称为网址/ws/users/signup/sometokenvalue
我想验证用户的电子邮件ID,并希望通过电子邮件发送一个URL,该URL应与GET
映射到domain.com/ws/users/signup/sometokenvalue
请求。我该如何在Play / Scala中做到这一点?
目前,我正在手动创建url
,但是它显然不可扩展且容易出错。
val url = s"http://localhost:9000/ws/users/signup/${userToken.tokenId}";
val html =s"<a href=${url}>Click here to verify email</a>"
println("html is "+html)
val email = mailerService.sendEmail("welcome","signup@mydomain.com",List(user.profile.externalProfileDetails.email),Some(userToken.toString),Some(html))