August 2019
Intermediate to advanced
256 pages
6h 43m
English
MP-RC supports both programmatic lookup and CDI injection approaches for usage. An example of a REST service making use of org.eclipse.microprofile.rest.client.RestClientBuilder to create a type-safe client for the WorldClockApi interface is listed in the following as WorldClockUser.java:
package io.pckt.restc.contract;import javax.ws.rs.GET;import javax.ws.rs.Path;import javax.ws.rs.PathParam;import javax.ws.rs.Produces;import javax.ws.rs.core.MediaType;@Path("/api")@ApplicationScopedpublic class WorldClockUser { @GET @Path("/now-utc") @Produces(MediaType.TEXT_PLAIN) public String getCurrentDateTime() { WorldClockApi remoteApi = RestClientBuilder.newBuilder() .baseUri(URI.create(WorldClockApi.BASE_URL)) ...Read now
Unlock full access