xenit-eu / java-hal-client

Hateoas and Hal client for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ContentGrid HAL Forms Client

Context

This is a minimal HAL and HAL-FORMS client, to be used with integration tests.

Usage

var halFormsClient = HalFormsClient.builder().restClient(restClient).build();

var orgs = halFormsClient.follow(HalLink.from(URI.create("http://api.contentgrid.test/orgs")));
var myOrg = halFormsClient.requestDefaultTemplate(orgs)
        .properties(Map.of("display_name", "test"))
        .execute().toHalDocument();

var projects = halFormsClient.follow(myOrg.getRequiredLink("projects"));
var testProject = halFormsClient.requestDefaultTemplate(projects)
        .properties(Map.of("name", "test"))
        .execute().toHalDocument();

Possible improvements

  • More explicit support for OAuth2 clients
  • Use Spring HATEOAS concepts: RepresentationModel<T>
  • Use Spring HATEOAS / Traverson concepts: LinkRelation, LinkDiscoverer, ...
  • Base internals on RestOperations to improve testability, potentially using RestOperationsAdapter
  • Add support to automatically follow redirects (HTTP 302)
  • Let DefaultHalFormsClient extend DefaultHalClient to avoid duplication (possibly via ServiceLoader)

About

Hateoas and Hal client for Java

License:Apache License 2.0


Languages

Language:Java 100.0%