/** * Take an {@link Employee} and get the URI using Spring Data REST's {@link EntityLinks}. * * @param employee */ private String getPath(Employee employee) { return this.entityLinks.linkForSingleResource(employee.getClass(), employee.getId()).toUri().getPath(); }
/** * Take an {@link Employee} and get the URI using Spring Data REST's {@link EntityLinks}. * * @param employee */ private String getPath(Employee employee) { return this.entityLinks.linkForSingleResource(employee.getClass(), employee.getId()).toUri().getPath(); }
@PostMapping public HttpEntity<FooResource> create(@RequestBody FooResource fooResource) { HttpHeaders headers = new HttpHeaders(); Foo entity = new Foo(fooResource.getUuid(), "Foo"); // ... headers.setLocation(entityLinks.linkForSingleResource(FooResource.class, UuidHelper.toFriendlyId(entity)).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
@PostMapping public HttpEntity<FooResource> create(@RequestBody FooResource fooResource) { HttpHeaders headers = new HttpHeaders(); Foo entity = new Foo(fooResource.getUuid(), "Foo"); // ... headers.setLocation(entityLinks.linkForSingleResource(FooResource.class, UuidHelper.toFriendlyId(entity)).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }