hateoas

CQRS and REST HATEOAS mismatch

旧城冷巷雨未停 提交于 2019-11-30 17:50:00
问题 Suppose you have a model Foo. One business case is to simply create an instance of Foo, so there is a corresponding CreateFooCommand in my model, triggered by invoking a POST request to a given REST endpoint. There are of course other Commands too. But now, there is a ViewModel, which is derived from my DomainModel. It's simply a sql table with raw data - each Foo instance from DomainModel has corresponding derived ViewModel instance. Both have different IDs (on DomainModel there is a

Single Page Application and RESTful API

情到浓时终转凉″ 提交于 2019-11-30 15:31:25
问题 A real RESTful API leverages hypermedia so that clients rely only on dynamic hypermedia provided by server to navigate through the application (the concept known as HATEOAS) This concept is easily applicable to web applications but how do you apply it to Single Page Application as SPAs normally manage their state internally (without relying on the server as far as navigation is concerned) ? My feeling is that SPAs cannot fully leverage RESTful APIs or did I miss something ? Thanks Riana 回答1:

How to establish relationships between Spring Data REST / Spring HATEOAS based (micro) services?

不羁岁月 提交于 2019-11-30 14:03:59
Trying to figure out a pattern for how to handle relationships when using a hypermedia based microservices based on Spring Data Rest or HATEOAS. If you have service A (Instructor) and Service B (Course) each exist as an a stand alone app. What is the preferred method for establishing a relationship between the two services. In a manner that does not require columns for IDs of the foreign service. It would be possible for each service to have many other services that need to communicate in the same manor. Possible solution (Not sure a correct path) Each service has a second table with a

Returned json unexpected, has “links” spelled as “_links” and structure different, in Spring hateoas

試著忘記壹切 提交于 2019-11-30 12:59:08
As the title says, I have a resource object Product extending ResourceSupport . However, the responses I receive have the property "_links" instead of "links" and have a different structure. { "productId" : 1, "name" : "2", "_links" : { "self" : { "href" : "http://localhost:8080/products/1" } } } Based on the HATEOAS Reference , the expected is: { "productId" : 1, "name" : "2", "links" : [ { "rel" : "self" "href" : "http://localhost:8080/products/1" } ] } Was this intended? Is there a way to change it, or at leas the "link" if not the structure? I added the selfLink through the following

Versioning a RESTful API with both XML and JSON Content-Type

丶灬走出姿态 提交于 2019-11-30 11:34:58
问题 According to this excellent presentation on designing RESTful interfaces, the preferred way to implement versioning is to utilize the Accept-header, using something like: GET /products HTTP/1.1 Host: example.com Accept: application/vnd.com.myservice.v2+xml This works perfectly for XML Content-Types, but is possible to use the same scheme for versioning the JSON-equivalent ? I.e, is it possible to ask for: GET /products HTTP/1.1 Host: example.com Accept: application/vnd.com.myservice.v2+json

HATEOAS - How to model link relations that change state

对着背影说爱祢 提交于 2019-11-30 04:18:58
问题 Following HATEOAS principles that each states should be hyperlinked, what is the best way to model links that change resource state? Let's take classical example with orders: { id : 12, state: 'pending', ..., links: [ ..., { rel: 'cancel', href: '/orders/12/cancel' }, ... ] } I am not totall happy with that "/cancel" part - I would feel a lot better if I could send " PUT " request with contents: { status:'cancelled' } But how do I represent that with "href" attribute in links section? I would

JSON Hypermedia Api with forms and links

China☆狼群 提交于 2019-11-30 02:22:25
I am in the early stages of planning a REST api, and I would like for it to adhere to the HATEOAS constraint of REST. But I would also like to provide a JSON format. So my question is if there are conventions out there to represent links and forms in JSON. I have found examples of links, and it looks like this is a pretty common way of representing links: "links": [ {"rel": "self", "href":"http://example.org/entity/1"}, {"rel": "friends", "href":"http://example.org/entity/1/friends"}] Representing forms on the other hand, is not something that I have seen much of. I was thinking that perhaps

HATEOAS: absolute or relative URLs?

与世无争的帅哥 提交于 2019-11-29 21:16:59
In designing a RESTful Web Service using HATEOAS, what are the pros and cons of showing a link as a complete URL (" http://server:port/application/customers/1234 ") vs. just the path ("/application/customers/1234")? RayLuo There is a subtle conceptual ambiguity when people say "relative uri". By RFC3986's definition , a generic uri contains: URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] hier-part = "//" authority path-abempty / path-absolute / path-rootless / path-empty foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | |

How should HATEOAS-style links be implemented for RESTful JSON collections?

两盒软妹~` 提交于 2019-11-29 20:09:48
To keep things simple and to avoid nameing collisions, I've been bundling links in my record resources like this... { id: 211, first_name: 'John', last_name: 'Lock', _links: [ { rel: 'self', href: 'htttp://example.com/people/211' } ] } However, I can't work out how to implement links in collections. I have spent a long time trawling around the web for examples and other than using the not so lean HAL I'm unable to reconcile my problem. [ {id:1,first_name:.....}, {id:2,first_name:.....}, {id:3,first_name:.....}, "_links": "Cant put a key value pair here because its an-array" ] Which means I

what is hypermedia , hypermedia controls, hypermedia formats

别等时光非礼了梦想. 提交于 2019-11-29 19:06:19
I'm currently reading "Rest in practice" book . I'm unable to understand the following terminology Hypermedia , hypermedia format, hypermedia controls, Domain application protocol. The author was suggesting need for domain specific hypermedia format. I could hardly understand those. I googled these terms but couldnt find a right answer. Can anyone explain these terminologies and why we need domain specific hypermedia formats instead of application/xml ? Hypermedia = the fact that client and server are talking in terms of some a uniform representation eg: hyper links. HyperMedia Control = A