Announcement Announcement Module
Collapse
No announcement yet.
Cross-Application Rest API Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cross-Application Rest API

    as far as I can tell these forums don't get much use, but i figured i'd ask this here as well as stack overflow:


    So let's assume I have two applications, the Person application that manages people, and the Pants application that manages Pants. In the Person application the Domain object Person has a List pantsId that refers to the id of a pair of pants from the Pants application.

    I'm not sure how to model this using Spring Data Rest so that when I serialize the person, I am able to embed a link to the external Pants application's pants instances. [or even to have /person/123/pants return a list of those external pants resources]

    Looking for something along the lines of the below:

    Code:
    GET http://www.mydomain.com/personapp/person/123:
    {
      "name" : "bob",
      "age": "30",
    
      "_links" : {
        "self" : {
          "href" : "http://www.mydomain.com/personapp/person/123"
        },
        "pants" : {
          "href" : "http://www.mydomain.com/pantsapp/pants/456"
          "href" : "http://www.mydomain.com/pantsapp/pants/789"
        }
      }

  • #2
    Hi Madorb.

    You need to create a ResourceProcessor. As an example:

    @Component
    public class PersonResourceProcessor implements ResourceProcessor<Resource<Person>> {

    @Override
    public Resource<Instituicao> process(Resource<Instituicao> resource) {
    resource.add(new Link("http://www.mydomain.com/pantsapp/pants/456").withRel("pants"));
    return resource;
    }

    }

    Comment

    Working...
    X