【发布时间】:2015-11-04 10:15:38
【问题描述】:
我有这个端点:
@POST
@Path("login")
@Consumes(MediaType.APPLICATION_JSON)
public Response doLogin(LoginCredentials loginCredentials) {
try {
usersService.validate(loginCredentials);
return Response.ok().build();
} catch (InvalidCredentialsException e) {
return Response.status(Response.Status.UNAUTHORIZED).build();
} catch (NotAuthorizedUserException e) {
return Response.status(Response.Status.UNAUTHORIZED).build();
}
}
在UNAUTHORIZED 的情况下,我想发送一条消息来指定具体的错误。怎么能这样?
如果回复是ok,我会这样做:
返回Response.ok("Some message here").build();
【问题讨论】: