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。