Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We need dubbo-proxy can handle with form post or queryString #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.apache.dubbo.proxy.server;

import com.alibaba.fastjson.JSON;

import com.google.common.base.Splitter;
import org.apache.dubbo.proxy.dao.ServiceDefinition;
import org.apache.dubbo.proxy.dao.ServiceMapping;
import org.apache.dubbo.proxy.metadata.MetadataCollector;
Expand Down Expand Up @@ -30,6 +32,7 @@ public class HttpProcessHandler extends SimpleChannelInboundHandler<FullHttpRequ
private MetadataCollector metadataCollector;
private ServiceMapping serviceMapping;
private Logger logger = LoggerFactory.getLogger(HttpProcessHandler.class);
private Splitter queryStringSplitter = Splitter.on(",").trimResults().omitEmptyStrings();


public HttpProcessHandler(int businessThreadCount, ServiceMapping serviceMapping, MetadataCollector metadataCollector) {
Expand Down Expand Up @@ -58,20 +61,37 @@ protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest msg) {
if (path.contains("/")) {
String application = path.split("/")[0];
String service = path.split("/")[1];
String methodName = null;
String[] paramTypes = null;
Map<String, List<String>> params = queryStringDecoder.parameters();
if (params.containsKey("group")) {
service = params.get("group").get(0) + "/" + service;
}
if (params.containsKey("version")) {
service = service + ":" + params.get("version").get(0);
}
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[]{});
}
}
ByteBuf raw = msg.content();
String info = raw.toString(CharsetUtil.UTF_8);
ServiceDefinition serviceDefinition = JSON.parseObject(info, ServiceDefinition.class);
serviceDefinition.setServiceID(service);
serviceDefinition.setApplication(application);
if (methodName != null && serviceDefinition.getMethodName() == null) {
serviceDefinition.setMethodName(methodName);
}
if (paramTypes != null && serviceDefinition.getParamTypes() == null) {
serviceDefinition.setParamTypes(paramTypes);
}
doRequest(ctx, serviceDefinition, msg);
} else {
} else {
//TODO error handle
}
}
Expand Down