wso2 api 管理器如何将自定义 header 添加到传递给后端的请求
How wso2 api manager add custom header to a request passing to backend
我在 WSO2 API 管理器中创建了一个 API,我想在 API 网关收到请求并设置自定义 [=] 时添加自定义 header 22=] 到 API 并将其传递给后端。
例如,当 API 网关接收到每个此类请求的请求时,都会将“My-Header : xxxxx”添加到请求中并将其传递给后端。
怎么可能?
您可以为此目的使用 custom sequence or header mediator。
从长远来看,你可以写一个custom handler你的具体目标。
您可以添加一个 in-sequnce 如下:
<sequence name="test" xmlns="http://ws.apache.org/ns/synapse">
<property name="<NAME>" value="<VALUE>" scope="transport"/>
<property name="<NAME>" value="<VALUE>" scope="transport"/>
</sequence>
您可以通过下面提到的各种方法实现此目的。
Publisher portal: 如果你想添加自定义 header 连同请求本身,你可以在发布者中按如下方式添加门户网站。
通过自定义中介:如果要在网关组件中添加自定义 header,可以使用 custom sequence built using a header mediator. This is appropriate to be used if your requirement is simple and doesn't have any complicated logic to be addressed. If you want to add the custom header to a specific API, then you can add the custom mediation only to that API. In case if you want to add it to all the APIs as a global solution, then you can add it as a global sequence.
通过自定义处理程序: 如果您在添加自定义 header 方面有复杂的要求,并且如果您想添加 header 在网关组件中,可以使用一个custom handler来实现。
我在 WSO2 API 管理器中创建了一个 API,我想在 API 网关收到请求并设置自定义 [=] 时添加自定义 header 22=] 到 API 并将其传递给后端。 例如,当 API 网关接收到每个此类请求的请求时,都会将“My-Header : xxxxx”添加到请求中并将其传递给后端。
怎么可能?
您可以为此目的使用 custom sequence or header mediator。
从长远来看,你可以写一个custom handler你的具体目标。
您可以添加一个 in-sequnce 如下:
<sequence name="test" xmlns="http://ws.apache.org/ns/synapse">
<property name="<NAME>" value="<VALUE>" scope="transport"/>
<property name="<NAME>" value="<VALUE>" scope="transport"/>
</sequence>
您可以通过下面提到的各种方法实现此目的。
Publisher portal: 如果你想添加自定义 header 连同请求本身,你可以在发布者中按如下方式添加门户网站。
通过自定义中介:如果要在网关组件中添加自定义 header,可以使用 custom sequence built using a header mediator. This is appropriate to be used if your requirement is simple and doesn't have any complicated logic to be addressed. If you want to add the custom header to a specific API, then you can add the custom mediation only to that API. In case if you want to add it to all the APIs as a global solution, then you can add it as a global sequence.
通过自定义处理程序: 如果您在添加自定义 header 方面有复杂的要求,并且如果您想添加 header 在网关组件中,可以使用一个custom handler来实现。