You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2019/07/31 10:25:06 UTC

[GitHub] [dubbo-proxy] qixiaobo commented on issue #15: We need dubbo-proxy can handle with form post or queryString

qixiaobo commented on issue #15: We need dubbo-proxy can handle with form post or queryString
URL: https://github.com/apache/dubbo-proxy/issues/15#issuecomment-516791470
 
 
   > I agree with you.
   > 一、对与原来设计的请求格式
   > 
   > > {application Name}/​{Interface name}?version={version}&group={group}
   > 
   > 我觉得可以把version和group放到request header里面去,这样就可以不干扰普通的get请求。
   > 
   > 二、 对与原来设计的请求参数
   > 
   > > {
   > > "methodName" : "sayHello",
   > > "paramTypes" : ["org.apache.dubbo.demo.model.User"],
   > > "paramValues": [
   > > {
   > > "id": 23,
   > > "username": "testUser"
   > > }
   > > ]
   > > }
   > 
   > 1. 把methodName也放到请求路径上去;
   > 2. 把paramTypes去掉,没有必要,json是松散的,解析后能对应上,就作为参数处理,对应不上,就为空;
   >    在请求头 增加参数解析与接口实际参数的匹配方式,可以做成3种等级:严格(每一个参数的名称和类型都要对应上)、较松散(参数的名称可以不完全一致,但类型必须一致)、松散(参数的名称和类型都可以不一致,全部对应不上,就全是空)
   > 3. 最后,就只剩下真正的参数了,完全符合网关的要求了。
   > 
   > 为了实现上面说的效果,不使用类似于过滤器的东西,好像是没有办法实现的吧
   
   From me , I just want make it compatible with  the old format.
   So I just add code like this 
   ```java
       private Splitter queryStringSplitter = Splitter.on(",").trimResults().omitEmptyStrings();
   ****
    if (params.containsKey("methodName")) {
                   methodName = params.get("methodName").get(0);
               }
               if (params.containsKey("paramTypes")) {
                   @SuppressWarnings("UnstableApiUsage") List<String> paramTypesList = queryStringSplitter.splitToList(params.get("paramTypes").get(0));
                   if (!paramTypesList.isEmpty()) {
                       paramTypes = paramTypesList.toArray(new String[]{});
                   }
               }
     if (methodName != null && serviceDefinition.getMethodName() == null) {
                   serviceDefinition.setMethodName(methodName);
               }
               if (paramTypes != null && serviceDefinition.getParamTypes() == null) {
                   serviceDefinition.setParamTypes(paramTypes);
               }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org