2.19.5. 在服务器上传播标头


org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory 的实例如果激活,可以批量传输传入的标头到传出请求。默认实例 org.eclipse.microprofile.rest.client.ext.DefaultClientHeadersFactoryImpl 将返回一个映射,这些映射由逗号分隔的配置属性 org.eclipse.microprofile.rest.client.propagateHeaders 中列出的。以下是实例化 ClientHeadersFactory 接口的规则:

  • 在 JAX-RS 请求上下文中调用的 ClientHeadersFactory 实例必须支持注入标有 @Context 的字段和方法。
  • 由 CDI 管理的 ClientHeadersFactory 实例必须使用适当的 CDI 管理的实例。它还必须支持 @Inject 注入。

org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory 接口定义如下:

public interface ClientHeadersFactory {

/**
 * Updates the HTTP headers to send to the remote service. Note that providers
 * on the outbound processing chain could further update the headers.
 *
 * @param incomingHeaders - the map of headers from the inbound JAX-RS request. This will
 * be an empty map if the associated client interface is not part of a JAX-RS request.
 * @param clientOutgoingHeaders - the read-only map of header parameters specified on the
 * client interface.
 * @return a map of HTTP headers to merge with the clientOutgoingHeaders to be sent to
 * the remote service.
 */
MultivaluedMap<String, String> update(MultivaluedMap<String, String> incomingHeaders,
                                      MultivaluedMap<String, String> clientOutgoingHeaders);
}

有关 ClientHeadersFactory 接口的更多信息,请参阅 ClientHeadersFactory Javadoc

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.