0
나는 그런Spring HATEOAS : 리소스 서비스를 광고하는 방법?
http://localhost:8080/user/1
로, 특정 리소스에 액세스하기위한 작업 봄 HATEOAS있어 그러나 나는 또한 서비스 URL을 광고 할 수 있도록하려면 : 당신이 할 경우, 예를 들어
http://localhost:8080/user
을 GET /, 내가 광고하는 서비스 자원을 반환하고 싶다. 지금은/auth만이 유일합니다.
{"links":[{"rel":"someString","href":"http://localhost/auth"}]}
: LINKTO 내가 가정 무효 인수를하지 않기 때문에 현재이 컴파일되지
@RequestMapping(value = "/", method = RequestMethod.GET)
@ResponseBody
public HttpEntity<AuthenticationResource> post() {
AuthenticationResource resource = new AuthenticationResource();
resource.add(linkTo(methodOn(AuthenticationController.class).authenticate()).withSelfRel());
return new ResponseEntity<AuthenticationResource>(resource, HttpStatus.OK);
}
@RequestMapping(value = "/auth", method = RequestMethod.POST, consumes = "application/json")
@ResponseBody
public void authenticate() {
//users.save(user);
}
는
것은 내가 원하는 것은이 내 인증합니다 메서드의 반환 형식입니다 HATEOAS 모범 사례에 머물면서 어떻게 이것을 수행합니까?
이것은 질문의 문제와 관련이 없지만 각 POST에서 작성하는 대신 Autowired AuthenticationResourceAssembler를 삽입해야합니다 ... –