hateoas

Generating Hypermedia links in a Web API

假装没事ソ 提交于 2019-12-03 05:47:14
问题 I'm curious to know how others have dealt with the issue of generating hypermedia links for their web APIs? Specifically, I'm using ASP.NET Web API, and am torn between having operations return hypermedia-related types, or returning the resource itself, and having the hypermedia stuff happen later in the pipeline. That is, do people tend to do things like: public Resource<Order> GetOrder(int id) { return new Resource<Order>() { Content = new Order(), Links = new LinkCollection<Order>() { new

How should I handle HATEOAS links and references in JSON? [closed]

自作多情 提交于 2019-12-03 00:47:45
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I'm in the process of designing a REST api and to be as RESTful as it gets. I want to incorporate HATEOAS into the json responses. Adding URLs to related resources is easy enough, but there was some discussion over the structure to use for those links. A LOT of articles I found use

Generating Hypermedia links in a Web API

徘徊边缘 提交于 2019-12-02 19:07:45
I'm curious to know how others have dealt with the issue of generating hypermedia links for their web APIs? Specifically, I'm using ASP.NET Web API, and am torn between having operations return hypermedia-related types, or returning the resource itself, and having the hypermedia stuff happen later in the pipeline. That is, do people tend to do things like: public Resource<Order> GetOrder(int id) { return new Resource<Order>() { Content = new Order(), Links = new LinkCollection<Order>() { new AddOrderLink(), new UpdateOrderLink()} } Or something more like public Order GetOrder(int id) { return

How should I handle HATEOAS links and references in JSON? [closed]

放肆的年华 提交于 2019-12-02 14:15:05
I'm in the process of designing a REST api and to be as RESTful as it gets. I want to incorporate HATEOAS into the json responses. Adding URLs to related resources is easy enough, but there was some discussion over the structure to use for those links. A LOT of articles I found use a structure borrowed from ATOM feeds: "links": [ {"rel": "self", "href":"http://example.org/entity/1"}, {"rel": "friends", "href":"http://example.org/entity/1/friends"}, ... ] This raised some questions: Why use an array as a container? According to a javascript developer I know, access to the links would be easier

How an RPC-style example would look modelled in a resource-centric style

安稳与你 提交于 2019-12-02 12:29:22
I have been reading around the web about REST for several days now and am struggling with the concept of HATEOAS. I think I am struggling because I don't properly understand how to model data as resources and (state-transitioning?) links between resources. I believe my problem is that all my experience is OO and RPC and I am unused to thinking in a resource-centric manner. The only way to get an understanding is to take an example from my world, say what I think that might look like modelled in a resource/link-centric manner and throw it out there to be shot down in flames. After the burn is

How to loop and retrieve value from HATEOAS _link attribute (e.g. retrieve a description)?

瘦欲@ 提交于 2019-12-02 11:19:33
tl;dr My code gets an array of javascript/json objects from a Restful GET. How do I write code to loop and retrieve, for display, a description (or any value) from a HATEOAS "_link" attribute? Context I've inherited a small Spring-based project --it tracks servers, software installations, etc for our team's internal use. It uses Angular front end and Spring/java/mysql back end for a restful back end. I'm in the process of converting the hand-coded SQL to JPA and 'spring starter data rest' Current API Does The current handcoded SQL joins tables to give "display friendly results". Product ------

How to add HATEOAS links in a sub resource

喜欢而已 提交于 2019-12-02 03:08:07
I have a parent resource called the AdminResource and a child resource called the AdminModuleResource. The resource of the parent is correctly fitted with HATEOAS links: { "firstname" : "Stephane", "lastname" : "Eybert", "email" : "mittiprovence@yahoo.se", "password" : "e41de4c55873f9c000f4cdaac6efd3aa", "passwordSalt" : "7bc7bf5f94fef7c7106afe5c3a40a2", "links" : [ { "rel" : "self", "href" : "http://localhost/admins/3683" }, { "rel" : "modules", "href" : "http://localhost/admins/3683/modules" } ], "id" : 3683 } The resource of the child is also correctly fitted with HATEOAS links: { "module"

angular2/http get location header of 201 response

心不动则不痛 提交于 2019-12-01 20:55:24
问题 I finished successfully the angular2 "tour of heroes" starter tutorial. Then I build an api based on symfony3, FosRestBundle and BazingaHateoasBundle as backend. Now nearly everything works, but on creating new items I'm not able to get the "Location" header from the response to load the newly created Item. Here is my Hero Service: import {Injectable} from "angular2/core"; import {Hero} from "./hero"; import {Http, Headers, RequestOptions, Response} from "angular2/http"; import {Observable}

Single Page Application and RESTful API

你离开我真会死。 提交于 2019-11-30 21:15:43
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 A SPA's particularity is it provides a more fluid user experience with the UI constructed on the client

Optionally disable HATEOAS format in Spring Data Rest

自古美人都是妖i 提交于 2019-11-30 18:02:05
So let's say I have an existing application that has two endpoints /people and /pants. Calling GET /people returns: [ { "name":"john", "age":37, "pants":[ { "color":"green", "brand":"levis", "size":"medium" }, { "color":"indigo", "brand":"jncos", "size":"medium-with-huge-legs" } ] }, { "name":"june", "age":23, "pants":[ { "color":"pink", "brand":"gap", "size":"small" } ] } ] If i were to use Spring Data Rest and call GET /person i'd receive something like: { "_links":{ "next":{ "href":"http://myapp.com/people?page=1&size=20" }, "self":{ "href":"http://myapp.com/people{&page,size,sort}",