|
|
|
@ -16,6 +16,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Comparator; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
@ -50,6 +51,7 @@ public class ApiMetaBuilder { |
|
|
|
|
Set<RequestMappingInfo> requestMappingInfos = handlerMethods.keySet(); |
|
|
|
|
List<String> store = new ArrayList<>(); |
|
|
|
|
List<ServiceApiInfo.ApiMeta> apis = new ArrayList<>(requestMappingInfos.size()); |
|
|
|
|
Set<ServiceApiInfo.ApiMeta> restfulApis = new HashSet<>(requestMappingInfos.size()); |
|
|
|
|
|
|
|
|
|
for (Map.Entry<RequestMappingInfo, HandlerMethod> handlerMethodEntry : handlerMethods.entrySet()) { |
|
|
|
|
ServiceApiInfo.ApiMeta apiMeta = this.buildApiMeta(handlerMethodEntry); |
|
|
|
@ -57,6 +59,9 @@ public class ApiMetaBuilder { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
String key = apiMeta.fetchNameVersion(); |
|
|
|
|
if (apiMeta.isOriginalMapping()) { |
|
|
|
|
restfulApis.add(apiMeta); |
|
|
|
|
} else { |
|
|
|
|
if (store.contains(key)) { |
|
|
|
|
throw new IllegalArgumentException("重复申明接口,请检查path和version,path:" + apiMeta.getPath() + ", version:" + apiMeta.getVersion()); |
|
|
|
|
} else { |
|
|
|
@ -64,6 +69,8 @@ public class ApiMetaBuilder { |
|
|
|
|
} |
|
|
|
|
apis.add(apiMeta); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
apis.addAll(restfulApis); |
|
|
|
|
return apis; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -93,11 +100,11 @@ public class ApiMetaBuilder { |
|
|
|
|
if (!ServiceContext.getCurrentContext().getBoolean(ServiceContext.RESTFUL_KEY, false)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
// 如果是restful服务
|
|
|
|
|
String path = patterns.iterator().next(); |
|
|
|
|
if (path.contains("$") || isIgnorePattern(path)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
// 如果是restful服务
|
|
|
|
|
String name = path; |
|
|
|
|
String prefix = EnvironmentKeys.SOP_RESTFUL_PREFIX.getValue(); |
|
|
|
|
if (StringUtils.isEmpty(prefix)) { |
|
|
|
|