paramMapping is used to edit your request parameters.Core Module shenyu-plugin-param-mapping
Core Class org.apache.shenyu.plugin.param.mapping.ParamMappingPlugin
paramMapping dependency in the pom.xml file of the gateway.<!-- apache shenyu param_mapping plugin start--> <dependency> <groupId>org.apache.shenyu</groupId> <artifactId>shenyu-spring-boot-starter-plugin-param-mapping</artifactId> <version>${project.version}</version> </dependency> <!-- apache shenyu param_mapping plugin end-->
shenyu-admin --> BasicConfig --> Plugin --> paramMapping set Status enabled.Selectors and rules, please refer to:Selector And Rule Config。
Only those matched requests can be modified your request body.
param details:
addParameterKeys: add a new key-value on bodyreplaceParameterKeys: replace request body's key ,key is the value to be replaced,value is the value after replacementremoveParameterKeys: remove a body keyparam_mapping modify the request body is achieved through JSONPath , $. represents the root directory.
use the configuration,unopened the plugin,request body is:
{"id":3,"data":{"value":"18","age":"36"}}
open the plugin,the final request body is
{"name":"shenyu","userId":3,"data":{"age":"36"}}
add a new key-value name:shenyu,replace the key id to userId, remove the key data.value .
shenyu-admin --> BasicConfig --> Plugin --> paramMapping set Status disable.