-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a quickstart for the default REST Client
Let's make it consistent with the RESTEasy Client
- Loading branch information
Showing
5 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...arts/quarkus/extension-codestarts/rest-client-codestart/base/README.tpl.qute.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{#include readme-header /} |
13 changes: 13 additions & 0 deletions
13
...ain/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/codestart.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: rest-client-codestart | ||
ref: rest-client | ||
type: code | ||
tags: extension-codestart | ||
metadata: | ||
title: REST Client | ||
description: Invoke different services through REST with JSON | ||
related-guide-section: https://quarkus.io/guides/rest-client | ||
language: | ||
base: | ||
dependencies: | ||
- io.quarkus:quarkus-rest-client | ||
- io.quarkus:quarkus-rest-client-jackson |
37 changes: 37 additions & 0 deletions
37
...tension-codestarts/rest-client-codestart/java/src/main/java/org/acme/MyRemoteService.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.acme; | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.QueryParam; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* To use it via injection. | ||
* | ||
* {@code | ||
* @Inject | ||
* @RestClient | ||
* MyRemoteService myRemoteService; | ||
* | ||
* public void doSomething() { | ||
* Set<MyRemoteService.Extension> restClientExtensions = myRemoteService.getExtensionsById("io.quarkus:quarkus-hibernate-validator"); | ||
* } | ||
* } | ||
*/ | ||
@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") | ||
public interface MyRemoteService { | ||
|
||
@GET | ||
@Path("/extensions") | ||
Set<Extension> getExtensionsById(@QueryParam("id") String id); | ||
|
||
class Extension { | ||
public String id; | ||
public String name; | ||
public String shortName; | ||
public List<String> keywords; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...nsion-codestarts/rest-client-codestart/kotlin/src/main/kotlin/org/acme/MyRemoteService.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.acme | ||
|
||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient | ||
import jakarta.ws.rs.GET | ||
import jakarta.ws.rs.Path | ||
import jakarta.ws.rs.QueryParam | ||
|
||
/** | ||
* To use it via injection. | ||
* | ||
* ```kotlin | ||
* @Inject | ||
* @RestClient | ||
* lateinit var myRemoteService: MyRemoteService | ||
* | ||
* fun doSomething() { | ||
* val restClientExtensions = myRemoteService.getExtensionsById("io.quarkus:quarkus-rest-client") | ||
* } | ||
* ``` | ||
*/ | ||
@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") | ||
interface MyRemoteService { | ||
|
||
@GET | ||
@Path("/extensions") | ||
fun getExtensionsById(@QueryParam("id") id: String): Set<Extension> | ||
|
||
data class Extension(val id: String, val name: String, val shortName: String, val keywords: List<String>) | ||
} |
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