hateoas

Spring Data Rest - _links

邮差的信 提交于 2019-12-05 02:53:05
问题 Edit 14/08/14 13:29 My next conclusion is that the hal+json format produced from my @RepositoryRestResource CrudRepository is incorrect. The tutorial (http://spring.io/guides/gs/accessing-data-rest/) shows the output of a hypermedia Rest JPA entity as: (please note there is no "rel" element, and "links" is not an array) { "_links" : { "people" : { "href" : "http://localhost:8080/people{?page,size,sort}" } } } However, the reference docs (http://docs.spring.io/spring-data/rest/docs/1.1.x

What is the importance of the self link in hypermedia APIs?

我们两清 提交于 2019-12-04 22:42:55
All the articles and books I read on REST repeat the importance of adding "self" rel links to your hypermedia responses but they're all light on the reasons and use cases. Why should you add a self link and how is it useful? fumanchu The main reason is that clients (and even some servers) do not store the location of a representation with the representation. For example, if you wget http://.../foo.json , the representation will be saved to disk, but the URI at which it was fetched will not be. If there is no "self" link embedded in the representation, this causes two problems: Relative links

How to handle sensitive properties in a RESTful API (such as passwords, credit cards, etc)

僤鯓⒐⒋嵵緔 提交于 2019-12-04 14:17:19
Working on a REST framework that will support multiple hypermedia types and authentication. One thing I'm not really sure how to handle are sensitive values in the resources. For instance, if I were to include user management in the API, I would need a way to expose to the client that there was a field for the password, but not show the actual password hash. Same thing with a credit card. If I don't, it would violate the hypermedia constraint as knowledge of the fields would become out of band, and make my HATEOAS broken. Here's an actual use case that I've encountered: The project is a

Spring HATEOAS Resource Assembler and Resource Links with many variables

烈酒焚心 提交于 2019-12-04 11:45:48
I'm working on REST API with Spring HATEOAS and the Spring stack, and i have some problems with links into resources. Here is my code : the Controller : @RestController @RequestMapping("/apporteurs/{idInt}/ribs") public class RibController { @Autowired private RibResourceAssembler ribResourceAssembler; @Autowired private RibRepository ribRepository; /** * Methode GET permettant d'obtenir un Rib par son ID * * @param idRib ID du Rib * @return RibResource */ @RequestMapping(value = "/{idRib}", method = RequestMethod.GET) @ResponseBody public RibResource getRibById(@PathVariable Long idInt,

Consuming Spring Hateoas Pageable

醉酒当歌 提交于 2019-12-04 07:12:11
I have a Rest-Service using HAteoas, what worked before without pageing. Now I am producing pageable Json. I did it with out-of-the box features from Spring-Hateoas. But now I am stucking consuming it and I guess it is really not well documented, if it is. My JSON looks like follows: { "_embedded": { "vertragResourceList": [ { "identifier": 728, "auszubildender": "Rumm", "beruf": "Landwirt/in", "betrieb": "Mitterbauer Johann", "betriebsNummer": "e12d0949-67ae-4134-9dc2-fb67758b6b16", "zustaendigeStelle": "Irgendwo", "beginn": 529887600000, "status": "RECENT", "fachrichtung": null, "schwerpunkt

Why most API paginations do not rely on HTTP Range header?

时间秒杀一切 提交于 2019-12-04 02:16:34
I've searched a lot but I can't find a good answer to this question. Being a HATEOAS aficionado, I would think that this header fit perfectly: Range: item=1-20/100 In the HTTP spec, I don't understand some "contradictions": The range unit can accept "other-range-unit"... range-unit = bytes-unit | other-range-unit bytes-unit = "bytes" other-range-unit = token ... yet the spec is later explicit: The only range unit defined by HTTP/1.1 is "bytes". HTTP/1.1 implementations MAY ignore ranges specified using other units. Finally the spec ends with this statement: HTTP/1.1 has been designed to allow

Spring HATEOAS versus Spring Data Rest

醉酒当歌 提交于 2019-12-03 18:22:11
问题 Question is, what's the difference between Spring HATEOAS versus Spring Data Rest ? I feel both can do the same, and Spring Data Rest (as part of Spring Data) seems a bit more alive. https://github.com/spring-projects/spring-hateoas https://github.com/spring-projects/spring-data-rest When would you use one or the other? 回答1: Spring HATEOAS provides common abstractions (representational models, a Link class, API to build links pointing to Spring MVC controllers, etc.) to ease building

Spring Data Rest - _links

心不动则不痛 提交于 2019-12-03 17:21:16
Edit 14/08/14 13:29 My next conclusion is that the hal+json format produced from my @RepositoryRestResource CrudRepository is incorrect. The tutorial ( http://spring.io/guides/gs/accessing-data-rest/ ) shows the output of a hypermedia Rest JPA entity as: (please note there is no "rel" element, and "links" is not an array) { "_links" : { "people" : { "href" : "http://localhost:8080/people{?page,size,sort}" } } } However, the reference docs ( http://docs.spring.io/spring-data/rest/docs/1.1.x/reference/html/intro-chapter.html ) show that the output should be: { "links" : [ { "rel" : "customer",

Meaning and usage of “_embedded” in HATEOAS

扶醉桌前 提交于 2019-12-03 11:47:12
问题 I'm using Spring Data REST, which supports HATEOAS. I'm new to this paradigm. In GET responses from my RESTful web service I often receive results inside a node named _embedded . I'm wondering: what is _embedded node for? Is it part of REST specification? Or part of HATEOAS specification? Or is it specific for the Spring implementation of them? This is an example of JSON result for GET http://localhost:8080/mywebservice/features : { "_links": { "search": { "href": "http://localhost:8080

How to expose a complete tree structure with Spring Data REST and HATEOAS?

拈花ヽ惹草 提交于 2019-12-03 08:37:52
I have a JPA tree structure @Entity public class Document { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; private String text; @ManyToOne @JoinColumn(name = "parent") Document parent; @OneToMany(mappedBy = "parent", fetch = FetchType.EAGER) Set<Document> children; (getters and setters) } and a projection @Projection(name = "all", types = Document.class) public interface AllDocumentsProjection { int getId(); String getText(); Set<Document> getChildren(); } When I make a GET request with url localhost:8080/documents/1?projection=all I only get the first children of the root