hateoas

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

余生颓废 提交于 2019-12-12 07:15:23
问题 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

How to access one element of a REST collection through HATEOAS links?

ぐ巨炮叔叔 提交于 2019-12-11 12:18:33
问题 I'm trying to build an architecture of RESTful services, and to build a gateway service for all of those, with Java Spring. In order to make the latter, I need to implement a client for the other services, which me and my colleagues tried to design around the HATEOAS principle, by providing links to related resources through spring-hateoas module. Let's say I have a service running on localhost, listening on 8080 port, which returns a collection of resources with a GET operation on /resources

HATEOAS and links/actions

江枫思渺然 提交于 2019-12-11 04:46:55
问题 I'm trying to wrap my head around how to (and if to) implement HATEOAS in my api. I like one of the concept of feeding the client only actions that are appropriate in the current situation. However I'm not sure if I'm implementing this idea correctly. Let's say I have a resource type order with a status that can be changed, it can have different statuses ( processing , accepted , declined , expired , successful). Should I then create the following json object: { ... "links": { "accept": "http

Jersey linking support with Google App Engine issue

[亡魂溺海] 提交于 2019-12-11 02:56:41
问题 I didn't manage to use the Jersey linking support with Google App Engine, I'm getting these exceptions when trying to access the application : Caused by: javax.el.ELException: Could not find expression factory class ... Caused by: java.lang.ClassNotFoundException: de.odysseus.el.ExpressionFactoryImpl As specified in the documentation, I put this in the Jersey servlet section of the web.xml : <init-param> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name> <param

Follow all links in JSON-LD API

半城伤御伤魂 提交于 2019-12-11 02:26:04
问题 Say I want to consume an API that returns JSON-LD and follow all the links. (I'm experimenting with the Hydra API-Demo, but it should work with all JSON-LD APIs, not only Hydra-based ones. Any good APIs out there that I should try?) So I want to follow all the links and my environment doesn't have native RDF support. Probably, I should first parse it with one of the libs and get it into extended form with jsonld.expand() . Then I just grab all the values with key @id . Is that the recommended

Error on generating self link on pageable resource

非 Y 不嫁゛ 提交于 2019-12-10 16:39:21
问题 Make a simple RestController @RestController public class Controloler @Value class MyData { int value; } @GetMapping(value = "/datas", produces = MediaTypes.HAL_JSON_VALUE) public PagedResources<Resource<MyData>> getMyData(PagedResourcesAssembler<MyData> assembler, @RequestParam(required = false) String param, @PageableDefault Pageable pageRequest) { MyData data = new MyData(1); Page<MyData> page = new PageImpl<>(Collections.singletonList(data), pageRequest, 100); Link selfLink = linkTo

Link to another resource in a REST API: by its ID, or by its URL?

别等时光非礼了梦想. 提交于 2019-12-10 03:38:28
问题 I am creating some APIs using apiary, so the language used is JSON. Let's assume I need to represent this resource: { "id" : 9, "name" : "test", "customer_id" : 12, "user_id" : 1, "store_id" : 3, "notes" : "Lorem ipsum example long text" } Is it correct to refer to other resources by their IDs ( 12 , 1 , 3 ), or I should specify the URL of these resources (i.e. /customers/12 , /users/1 , /stores/3 )? I am not using HATEOAS and I am a bit confused. 回答1: DO include absolute entity URIs in your

Spring HATEOAS Resource Assembler and Resource Links with many variables

别说谁变了你拦得住时间么 提交于 2019-12-09 19:15:38
问题 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}",

Exposing link on collection entity in spring data REST

你离开我真会死。 提交于 2019-12-08 22:22:30
问题 Using spring data REST I have exposed a ProjectRepository that supports listing projects and performing CRUD operations on them. When I go to http://localhost:8080/projects/ I get the list of projects as I expect. What I am trying to do is add a custom action to the _links section of the JSON response for the Project Collection. For example, I'd like the call to http://localhost:8080/projects/ to return something like this: { "_links" : { "self" : { "href" : "http://localhost:8080/projects/{

spring rest data serialize to-one associations as related entity

牧云@^-^@ 提交于 2019-12-08 08:43:14
问题 How does one configure Spring Data Rest to serialize related entities directly ? I want it to look like this: note the "owner" link is to an "account" entity. { "name" : "customer", "_links" : { "self" : { "href" : "http://localhost:8081/api/v1/servers/1005" }, "owner" : { "href" : "http://localhost:8081/api/v1/account/100" } } } Currently (the default) has related entities (aka, associations) serialized indirectly. I DON'T want it to look like this: the "owner" link is via the self server