首页 > 解决方案 > 在 Quarkus 中调用具有自定义媒体类型的另一个服务的请求

问题描述

我正在开发公司内部的 Quarkus 服务。在这个服务中,我需要使用自定义的媒体类型异步调用另一个内部服务。

当我关注这个官方文档并写下这样的内容时:

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@Path("/api")
@RegisterRestClient
public interface InternalService {

  String CUSTOM_TYPE = "application/custom";

  @GET
  @Path("/hello/{id}")
  @Produces({CUSTOM_TYPE})
  Uni<EntityClass> getHello(@PathParam("id") long id);
}

在我的情况下,这EntityClass实际上是 protobuf 消息。

在示例中(https://quarkus.io/guides/rest-client),看起来可以直接注入 bean:

    @Inject
    @RestClient
    CountriesService countriesService;

我有几个问题:

  1. 是否resteasy已经提供了常见媒体类型的实现?
  2. 如何InternalService为我的自定义媒体类型实现接口?

标签: javarestmime-typesquarkus

解决方案



推荐阅读