TODO: RestController Http2Dubbo

This commit is contained in:
huangsimin 2019-06-25 18:31:18 +08:00
parent 88de2eb5db
commit 53d572be7d
2 changed files with 19 additions and 9 deletions

View File

@ -33,6 +33,7 @@ import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.reactive.result.condition.PatternsRequestCondition; import org.springframework.web.reactive.result.condition.PatternsRequestCondition;
import org.springframework.web.reactive.result.condition.RequestMethodsRequestCondition; import org.springframework.web.reactive.result.condition.RequestMethodsRequestCondition;
import org.springframework.web.reactive.result.method.RequestMappingInfo; import org.springframework.web.reactive.result.method.RequestMappingInfo;
@ -40,6 +41,7 @@ import org.springframework.web.reactive.result.method.annotation.RequestMappingH
import org.springframework.web.util.pattern.PathPattern; import org.springframework.web.util.pattern.PathPattern;
import org.springframework.web.util.pattern.PathPatternParser; import org.springframework.web.util.pattern.PathPatternParser;
import cn.ecpark.service.usergw.impl.http.Http2Dubbo;
import cn.ecpark.service.usergw.utils.Convert; import cn.ecpark.service.usergw.utils.Convert;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -132,16 +134,12 @@ public class ConfigProperties {
} }
public static void createHttp2Dubbo(Map<String, Object> configDubbo) { public static void createHttp2Dubbo(Map<String, Object> configDubbo) {
// requestMapping.registerMapping(mapping, handler, method);
Method targetMethod = ReflectionUtils.findMethod(ApiController.class, getHandlerMethodName("")); // 找到处理该路由的方法
PathPatternParser pathPatternParser = new PathPatternParser();
PathPattern p = pathPatternParser.parse("/test/xixi");
PatternsRequestCondition patternsRequestCondition = new PatternsRequestCondition(p);
RequestMethodsRequestCondition requestMethodsRequestCondition = new RequestMethodsRequestCondition(getRequestMethod(requestMethod));
RequestMappingInfo mapping_info = new RequestMappingInfo(patternsRequestCondition, requestMethodsRequestCondition, null, null, null, null, null);
Method targetMethod = ReflectionUtils.findMethod(Http2Dubbo.class, "12"); // 找到处理该路由的方法
requestMapping.registerMapping(RequestMappingInfo.paths("/test/xixi").methods(RequestMethod.POST).build(),
applicationContext,
targetMethod);
// 引用远程服务 // 引用远程服务
try { try {

View File

@ -0,0 +1,12 @@
package cn.ecpark.service.usergw.impl.http;
import org.springframework.web.bind.annotation.RestController;
/**
* Http2Dubbo
*/
@RestController
public class Http2Dubbo {
}