Skip to content

Instantly share code, notes, and snippets.

@bgoetzmann
Created April 13, 2023 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgoetzmann/f55fbf9c95114b885873bb008cda5e4c to your computer and use it in GitHub Desktop.
Save bgoetzmann/f55fbf9c95114b885873bb008cda5e4c to your computer and use it in GitHub Desktop.
REST resource for restclient application
package odelia.restclient;
import javax.inject.Inject;
import javax.json.JsonObject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.eclipse.microprofile.rest.client.inject.RestClient;
@Path("/hello")
public class GreetingResource {
@Inject
@RestClient
SwapiService swapiService;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
JsonObject character = swapiService.getCharacter("1");
return character.getString("name");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment