0

I am very used to work with spring applications. While creating a webserver with spring boot I wanted to provide a client library for convenient access to the api endpoints.

Within this library I use Spring's RestTemplate because I am used to it's api. While creating this library I came over this:

private final RestTemplate restTemplate;

public HQConnection(RestTemplateBuilder restTemplateBuilder) {
  restTemplate = restTemplateBuilder.build();
}

And as I was writing my tests to see the API class actually being used I was using @Autowire to inject this component - normal thing for me since I am used to Spring's DI.

But then I realized something. What about those android developers who don't work with the Spring Framework? They have to actually instantiate the HQConnection by their own. This will be a big hassle since they have to get Spring into their app (if this is even possible?) to have access to a RestTemplateBuilder.

I was thinking "How can I make this API easy to use and hide the Spring detail?". I could not yet make up an answer and therefore asking for some guidance here.

xetra11
  • 7,671
  • 14
  • 84
  • 159

1 Answers1

1

Each environment and programming language will have its own frameworks to consume a REST API. E.g. relating to this so post or this blog post there are different ways to consume a REST API in android. In general, as a developer, you should not provide a custom consumer written with a specific language or specific frameworks.

Another example: Does the W3C give the browser-developer an example "http client"? I don't think so.

The cut of responsibility of a API developer is the API itself. Sure it should be user friendly and the API developer should help to develop the clients of the api-consumer-developer but you don't have to develop the clients.

kellyfj
  • 6,586
  • 12
  • 45
  • 66
r-vanooyen
  • 101
  • 1
  • 8