You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shenyu.apache.org by 张磊 <sa...@apache.org> on 2021/06/16 14:01:13 UTC
Add parameter-mapping and modify-response plugin
Hi everyone.
As of now,Shenyu has added lots plug-ins like request plugin and response
plugin.
I think we need some of the request body and response body modification
plugins.
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"
}
of course the plug-in needs to support other capabilities like add
a parameter.
If you have a good idea,please reply to this email and we can discuss it.
Thanks
issue : https://github.com/dromara/shenyu/issues/1621
Re: Add parameter-mapping and modify-response plugin
Posted by ttttangzhen <ta...@foxmail.com>.
For dubbo plugin ,I had finish this feature.It’s already support this now.
For others, like tars, sofa, Do we need provide this feature?
> 2021年6月17日 下午2:56,XiaoYu <xi...@apache.org> 写道:
>
> parameter
Re: Add parameter-mapping and modify-response plugin
Posted by XiaoYu <xi...@apache.org>.
Hi zhangleispring & tttangzhen
Now, dubbo already registers parameter types to metadata.
like this : java.lang.String ,java.lang.Integer ,
Should we make changes in the registration metadata? such as :
{"name":"java.lang.String", "age": "java.lang.Integer"}
ttttangzhen <ta...@foxmail.com> 于2021年6月17日周四 下午2:48写道:
> for many rpc plugin ,parameter type order is needed.
> I think parameter order is also one of the content of parameter mapping
>
> > 2021年6月17日 下午2:28,XiaoYu <xi...@apache.org> 写道:
> >
> > hi tttangzhen
> >
> > this is param order? maybe this plugin different parameters will be
> handled
> > depending on the rpc type.such as dubbo, http..
> >
> > ttttangzhen <ta...@foxmail.com> 于2021年6月17日周四 下午12:21写道:
> >
> >> 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.
> >>
> >> I hope the parameter-mapping plugin can solve this problem.
> >> Users can config the parameter type list, {"name":"java.lang.String",
> >> "age": "java.lang.Integer"}
> >>
> >>> 2021年6月16日 下午10:01,张磊 <sa...@apache.org> 写道:
> >>>
> >>> Hi everyone.
> >>> As of now,Shenyu has added lots plug-ins like request plugin and
> response
> >>> plugin.
> >>> I think we need some of the request body and response body modification
> >>> plugins.
> >>> 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"
> >>> }
> >>> of course the plug-in needs to support other capabilities like add
> >>> a parameter.
> >>>
> >>> If you have a good idea,please reply to this email and we can discuss
> it.
> >>> Thanks
> >>>
> >>> issue : https://github.com/dromara/shenyu/issues/1621
> >>
> >>
> >
>
>
Re: Add parameter-mapping and modify-response plugin
Posted by ttttangzhen <ta...@foxmail.com>.
for many rpc plugin ,parameter type order is needed.
I think parameter order is also one of the content of parameter mapping
> 2021年6月17日 下午2:28,XiaoYu <xi...@apache.org> 写道:
>
> hi tttangzhen
>
> this is param order? maybe this plugin different parameters will be handled
> depending on the rpc type.such as dubbo, http..
>
> ttttangzhen <ta...@foxmail.com> 于2021年6月17日周四 下午12:21写道:
>
>> 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.
>>
>> I hope the parameter-mapping plugin can solve this problem.
>> Users can config the parameter type list, {"name":"java.lang.String",
>> "age": "java.lang.Integer"}
>>
>>> 2021年6月16日 下午10:01,张磊 <sa...@apache.org> 写道:
>>>
>>> Hi everyone.
>>> As of now,Shenyu has added lots plug-ins like request plugin and response
>>> plugin.
>>> I think we need some of the request body and response body modification
>>> plugins.
>>> 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"
>>> }
>>> of course the plug-in needs to support other capabilities like add
>>> a parameter.
>>>
>>> If you have a good idea,please reply to this email and we can discuss it.
>>> Thanks
>>>
>>> issue : https://github.com/dromara/shenyu/issues/1621
>>
>>
>
Re: Add parameter-mapping and modify-response plugin
Posted by XiaoYu <xi...@apache.org>.
hi tttangzhen
this is param order? maybe this plugin different parameters will be handled
depending on the rpc type.such as dubbo, http..
ttttangzhen <ta...@foxmail.com> 于2021年6月17日周四 下午12:21写道:
> 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.
>
> I hope the parameter-mapping plugin can solve this problem.
> Users can config the parameter type list, {"name":"java.lang.String",
> "age": "java.lang.Integer"}
>
> > 2021年6月16日 下午10:01,张磊 <sa...@apache.org> 写道:
> >
> > Hi everyone.
> > As of now,Shenyu has added lots plug-ins like request plugin and response
> > plugin.
> > I think we need some of the request body and response body modification
> > plugins.
> > 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"
> > }
> > of course the plug-in needs to support other capabilities like add
> > a parameter.
> >
> > If you have a good idea,please reply to this email and we can discuss it.
> > Thanks
> >
> > issue : https://github.com/dromara/shenyu/issues/1621
>
>
Re: Add parameter-mapping and modify-response plugin
Posted by ttttangzhen <ta...@foxmail.com>.
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.
I hope the parameter-mapping plugin can solve this problem.
Users can config the parameter type list, {"name":"java.lang.String", "age": "java.lang.Integer"}
> 2021年6月16日 下午10:01,张磊 <sa...@apache.org> 写道:
>
> Hi everyone.
> As of now,Shenyu has added lots plug-ins like request plugin and response
> plugin.
> I think we need some of the request body and response body modification
> plugins.
> 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"
> }
> of course the plug-in needs to support other capabilities like add
> a parameter.
>
> If you have a good idea,please reply to this email and we can discuss it.
> Thanks
>
> issue : https://github.com/dromara/shenyu/issues/1621
Re: Add parameter-mapping and modify-response plugin
Posted by Kevin Clair <ke...@apache.org>.
Can it support generic types?
张磊 <sa...@apache.org> 于2021年6月16日周三 下午10:01写道:
> Hi everyone.
> As of now,Shenyu has added lots plug-ins like request plugin and response
> plugin.
> I think we need some of the request body and response body modification
> plugins.
> 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"
> }
> of course the plug-in needs to support other capabilities like add
> a parameter.
>
> If you have a good idea,please reply to this email and we can discuss it.
> Thanks
>
> issue : https://github.com/dromara/shenyu/issues/1621
>