public final class RestClients

  1. Object
  2. RestClients
Runtime registry that wires @RestClient-annotated interfaces to the build-time-generated implementations. The generated cn1app.RestClientBootstrap calls register(Class, Factory) for every API interface in the project; user code reaches them via the static of(String baseUrl) factory that cn1:generate-openapi puts on each interface, and that factory in turn calls create(Class, String) here.

Nested types

interface RestClients.FactoryFactory the generated bootstrap registers per API interface.

Methods

public static <T> void register(Class<T> apiType, RestClients.Factory<T> factory)Registers a factory for an @RestClient-annotated interface.
public static <T> T create(Class<T> apiType, String baseUrl)Returns a freshly-built client for the requested API.

Inherited methods

Method details

register

public static <T> void register(Class<T> apiType, RestClients.Factory<T> factory)
Registers a factory for an @RestClient-annotated interface. Called from the generated cn1app.RestClientBootstrap so the REST plumbing is set up before the first <Api>.of(baseUrl) call.

create

public static <T> T create(Class<T> apiType, String baseUrl)
Returns a freshly-built client for the requested API. Called by the static of(String baseUrl) factory emitted on every generated @RestClient interface.