javaspringspring-hateoas

Spring HATEOAS & HAL: Can I serve just Links but no content?


What it says in the title.

I want to serve a root resource that consists only of links to the "lower" resources. It seems that Resource as well as HttpEntity want an object with some content as their type, so how can I serve just Links?

Thanks.


Solution

  • So what you conceptually do is returning an empty collection resource with links attached. This can be achieved by this snippet of code:

    List<Link> links = …
    return new Resources<Object>(Collections.emptySet(), links);