shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

Add parameter-mapping plugin

Open SaberSola opened this issue 5 years ago • 5 comments

for example: if you request body is a json like this:{     "name":"saber",     "age":"18",     "id":" 12345" } 1.you want to replace the  key of  parameters "name" to "realName",you can use the parameter-mapping plugin modify the json ,then the body json is{     "realName":"saber",     "age":"18",     "id":" 12345" } 2.if you want remove a key, you can use the parameter-mapping plugin modify the json like {     "age":"18",     "id":" 12345" }

SaberSola avatar Jun 16 '21 14:06 SaberSola

assigned to me

SaberSola avatar Jun 16 '21 14:06 SaberSola

hi, @SaberSola I have a suggestion. For many rpc plugins, the request parameters are in strict order. So we can provide a function to adjust the order of parameters. I added this feature to the dubbo plugin before, I think it can be integrated into your plan

ttttangzhen avatar Jun 16 '21 14:06 ttttangzhen

HI,@ttttangzhen It’s good suggestion but the rpc call methods of Shenyu are all generalized. Is it necessary to strictly control the order of parameters?

SaberSola avatar Jun 16 '21 14:06 SaberSola

Generic service declares strict parameter order. For example, The parameter type list of an interface is (String name, Integer age). Our request body mast use {"name" : "mike","age": 12}. If we use {"age": 12, "name" : "mike"} or omit sending any parameters, It will throw an exception.

the parameter-mapping plugin can solve this problem. Users can config the parameter type list, {"name":"java.lang.String", "age": "java.lang.Integer"}

ttttangzhen avatar Jun 16 '21 15:06 ttttangzhen

@ttttangzhen Hi, pls discuss in [email protected]

yu199195 avatar Jun 17 '21 02:06 yu199195