Created
April 13, 2023 11:54
-
-
Save bgoetzmann/f55fbf9c95114b885873bb008cda5e4c to your computer and use it in GitHub Desktop.
REST resource for restclient application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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