Skip to content

6장 REST서비스 생성하기에서의 hateoas 변경사항 #4

@saechimdaeki

Description

@saechimdaeki

스프링 hateoas를 책과 다른 변경사항

  • ResourceSupport changed to RepresentationModel
  • Resource changed to EntityModel
  • Resources changed to CollectionModel
  • PagedResources changed to PagedModel
  • ResourceAssembler changed to RepresentationModelAssembler
  • ControllerLinkBuilder changed to WebMvcLinkBuilder
  • ResourceProcessor changed to RepresentationModelProcessor
    springframework에서의 hateoas가 위와 같이 변경되었습니다. 이를 고려해서 책을 보시면 됩니다!
    예를 들어 책 213쪽의 리스트 6.4 리소스에 하이퍼링크 추가하기를 이런식으로 변경하면 됩니다
        @GetMapping("/recent")
	public CollectionModel<EntityModel<Taco>> recentTacos(){
		PageRequest page=PageRequest.of(0, 12,Sort.by("createdAt").descending());
		
		List<Taco> tacos=tacoRepo.findAll(page).getContent();
		CollectionModel<EntityModel<Taco>> recentResources=CollectionModel.wrap(tacos);
		
		recentResources.add(new Link("http://localhost:8080/design/recent","recents"));
		return recentResources;
	}

p.s. spring 최신버젼으로 직접 코딩하시는분만...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions