Skip to main content
Version: 2.4.3

GeneralContext插件

说明#

  • Apache ShenYu 网关在对目标服务调用的时候,还容许用户使用 generalContext 插件在本次请求中通过读取header,进行服务上下文参数传递。

插件设置#

  • shenyu-admin--> 基础配置 --> 插件管理-> generalContext ,设置为开启。

  • 如果用户不需要,可以把插件禁用。

  • 在网关的 pom.xml 文件中添加 generalContext 的支持。
        <!-- apache shenyu general context plugin start-->        <dependency>            <groupId>org.apache.shenyu</groupId>            <artifactId>shenyu-spring-boot-starter-plugin-general-context</artifactId>            <version>${project.version}</version>        </dependency>        <!-- apache shenyu general context plugin end-->
  • 选择器和规则配置,请参考: 选择器和规则管理
  • 只有匹配的请求,并且配置规则才会传递上下文信息。

场景#

  • 需要对请求header中的参数传递至代理服务端。
  • 需要对请求header中的某个key进行替换后传递至代理服务端。