1

I’m working on a Spring Data Rest project and would like a way to effectively ‘split’ my API off two base roots / endpoints. For example, consider the root below:

{
"_links": {
    "orders": {
        "href": "http://localhost:8080/orders{?page,size,sort,projection}",
        "templated": true
    },
    "customers": {
        "href": "http://localhost:8080/customers{?page,size,sort,projection}",
        "templated": true
    },
    "profiles": {
        "href": "http://localhost:8080/profiles{?page,size,sort,projection}",
        "templated": true
    }
}
}

Now assume that I don’t really want my API consumers to mess with the profiles resource (they still technically can but its unsupported) but I still need it as part of my Rest API as my UI uses it. So what I really want is to base some of my APIs under “public/” and others under “internal/”

I.e.

{
"_links": {
    "orders": {
        "href": "http://localhost:8080/public/orders{?page,size,sort,projection}",
        "templated": true
    },
    "customers": {
        "href": "http://localhost:8080/public/customers{?page,size,sort,projection}",
        "templated": true
    },
    "profiles": {
        "href": "http://localhost:8080/internal/profiles{?page,size,sort,projection}",
        "templated": true
    }
}
}

The problem I have is that this doesn’t work as I believe Spring Data assumes the second level off my base (/) is the internal sub-resource. Is there any way I can achieve the above using Spring Data Rest?

fb08
  • 11
  • 1

1 Answers1

0

Typically if you want to customize the response you will want to utilize the Spring HATEOAS project.

code
  • 4,073
  • 3
  • 27
  • 47