Quarkus:请求 URL 作为字符串给出
Quarkus: request to URL given as string
我想用 Quarkus 发出 HTTP 请求。然而,目标 URL 在编译时是未知的,它将在运行时由不同的部分组成。
Quarkus 提供了一种构建静态 REST 客户端的方法,如下所示:
@Path("/v2")
@RegisterRestClient
public interface CountriesService {
@GET
@Path("/name/{name}")
@Produces("application/json")
Set<Country> getByName(@PathParam String name);
}
但是,我正在寻找类似 Python requests
包的东西:
url = 'https://whosebug.com/questions/ask'
response = requests.get(url)
我正在 Kotlin 中构建应用程序,因此所有 Java 和 Kotlin 库都应该可以工作。
我应该使用什么?
通过在接口中定义 MP REST 客户端,您可以使用程序化客户端创建 API:
CountriesService remoteApi = RestClientBuilder.newBuilder()
.baseUri("created at runtime url")
.build(CountriesService.class);
remoteApi.getByName("");
我想用 Quarkus 发出 HTTP 请求。然而,目标 URL 在编译时是未知的,它将在运行时由不同的部分组成。
Quarkus 提供了一种构建静态 REST 客户端的方法,如下所示:
@Path("/v2")
@RegisterRestClient
public interface CountriesService {
@GET
@Path("/name/{name}")
@Produces("application/json")
Set<Country> getByName(@PathParam String name);
}
但是,我正在寻找类似 Python requests
包的东西:
url = 'https://whosebug.com/questions/ask'
response = requests.get(url)
我正在 Kotlin 中构建应用程序,因此所有 Java 和 Kotlin 库都应该可以工作。
我应该使用什么?
通过在接口中定义 MP REST 客户端,您可以使用程序化客户端创建 API:
CountriesService remoteApi = RestClientBuilder.newBuilder()
.baseUri("created at runtime url")
.build(CountriesService.class);
remoteApi.getByName("");