I have this question that goes around my head for a while. Suppose we structured our project with a backend and interface at separate levels. So, from the interface, we want to get a costumer that comes in hal+json format:
GET /customers/1 HTTP/1.1 Accept: application/hal+json { "name": "Alice", "links": [ { "rel": "self", "href": "http://localhost:8080/customer/1" } { "rel": "transactions", "href": "http://localhost:8080/customer/1/transactions" }] }
Then from the external interface I want to get all transactions with clients. My question is: how do I get the URL? should it be from the answer? or should I build it internally?
if we move on to the first option, I think that perhaps it would not be elegant to iterate all the links until we get the one we need. In addition, a situation may occur when we do not have a link to the request that we want to make.
if we go with the second option, I don’t understand how to build this url if we actually have no identifiers. How can I create new transactions with clients if renoas replaces identifiers with links, and I no longer receive a reference to the object in the body?
I thought that perhaps the service should support both application/hal+json (user-oriented) and application/json (customer-oriented), but I don’t see that this is happening in general.
What do you think?
source share