Commit 8bf24e70 by Nepxion

重构路径

parent 048d6de3
......@@ -40,6 +40,7 @@ import com.nepxion.discovery.console.rest.VersionClearRestInvoker;
import com.nepxion.discovery.console.rest.VersionUpdateRestInvoker;
@RestController
@RequestMapping(path = "/console")
@Api(tags = { "控制台接口" })
public class ConsoleEndpoint {
private static final Logger LOG = LoggerFactory.getLogger(ConsoleEndpoint.class);
......@@ -53,73 +54,73 @@ public class ConsoleEndpoint {
@Autowired
private RestTemplate consoleRestTemplate;
@RequestMapping(path = "/console/services", method = RequestMethod.GET)
@RequestMapping(path = "/services", method = RequestMethod.GET)
@ApiOperation(value = "获取服务注册中心的服务列表", notes = "", response = List.class, httpMethod = "GET")
public List<String> services() {
return getServices();
}
@RequestMapping(path = "/console/instances/{serviceId}", method = RequestMethod.GET)
@RequestMapping(path = "/instances/{serviceId}", method = RequestMethod.GET)
@ApiOperation(value = "获取服务注册中心服务的实例列表", notes = "", response = List.class, httpMethod = "GET")
public List<ServiceInstance> instances(@PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId) {
return getInstances(serviceId);
}
@RequestMapping(path = "/console/instance-list/{serviceId}", method = RequestMethod.GET)
@RequestMapping(path = "/instance-list/{serviceId}", method = RequestMethod.GET)
@ApiOperation(value = "获取服务注册中心服务的实例列表(精简数据)", notes = "", response = List.class, httpMethod = "GET")
public List<InstanceEntity> instanceList(@PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId) {
return getInstanceList(serviceId);
}
@RequestMapping(path = "/console/instance-map", method = RequestMethod.GET)
@RequestMapping(path = "/instance-map", method = RequestMethod.GET)
@ApiOperation(value = "获取服务注册中心的服务和实例的Map(精简数据)", notes = "", response = Map.class, httpMethod = "GET")
public Map<String, List<InstanceEntity>> instanceMap() {
return getInstanceMap();
}
@RequestMapping(path = "/console/remote-config/update/{group}/{serviceId}", method = RequestMethod.POST)
@RequestMapping(path = "/remote-config/update/{group}/{serviceId}", method = RequestMethod.POST)
@ApiOperation(value = "推送更新规则配置信息到远程配置中心", notes = "", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> remoteConfigUpdate(@PathVariable(value = "group") @ApiParam(value = "组名", required = true) String group, @PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId, @RequestBody @ApiParam(value = "规则配置内容,XML格式", required = true) String config) {
return executeRemoteConfigUpdate(group, serviceId, config);
}
@RequestMapping(path = "/console/remote-config/clear/{group}/{serviceId}", method = RequestMethod.POST)
@RequestMapping(path = "/remote-config/clear/{group}/{serviceId}", method = RequestMethod.POST)
@ApiOperation(value = "清除规则配置信息到远程配置中心", notes = "", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> remoteConfigClear(@PathVariable(value = "group") @ApiParam(value = "组名", required = true) String group, @PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId) {
return executeRemoteConfigClear(group, serviceId);
}
@RequestMapping(path = "/console/remote-config/view/{group}/{serviceId}", method = RequestMethod.GET)
@RequestMapping(path = "/remote-config/view/{group}/{serviceId}", method = RequestMethod.GET)
@ApiOperation(value = "查看远程配置中心的规则配置信息", notes = "", response = ResponseEntity.class, httpMethod = "GET")
public ResponseEntity<?> remoteConfigView(@PathVariable(value = "group") @ApiParam(value = "组名", required = true) String group, @PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId) {
return executeRemoteConfigView(group, serviceId);
}
@RequestMapping(path = "/console/config/update-async/{serviceId}", method = RequestMethod.POST)
@RequestMapping(path = "/config/update-async/{serviceId}", method = RequestMethod.POST)
@ApiOperation(value = "批量异步推送更新规则配置信息", notes = "", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> configUpdateAsync(@PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId, @RequestBody @ApiParam(value = "规则配置内容,XML格式", required = true) String config) {
return executeConfigUpdate(serviceId, config, true);
}
@RequestMapping(path = "/console/config/update-sync/{serviceId}", method = RequestMethod.POST)
@RequestMapping(path = "/config/update-sync/{serviceId}", method = RequestMethod.POST)
@ApiOperation(value = "批量同步推送更新规则配置信息", notes = "", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> configUpdateSync(@PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId, @RequestBody @ApiParam(value = "规则配置内容,XML格式", required = true) String config) {
return executeConfigUpdate(serviceId, config, false);
}
@RequestMapping(path = "/console/config/clear/{serviceId}", method = RequestMethod.POST)
@RequestMapping(path = "/config/clear/{serviceId}", method = RequestMethod.POST)
@ApiOperation(value = "批量清除更新的规则配置信息", notes = "", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> configClear(@PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId) {
return executeConfigClear(serviceId);
}
@RequestMapping(path = "/console/version/update/{serviceId}", method = RequestMethod.POST)
@RequestMapping(path = "/version/update/{serviceId}", method = RequestMethod.POST)
@ApiOperation(value = "批量更新服务的动态版本", notes = "根据指定的localVersion更新服务的dynamicVersion。如果输入的localVersion不匹配服务的localVersion,则忽略;如果如果输入的localVersion为空,则直接更新服务的dynamicVersion", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> versionUpdate(@PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId, @RequestBody @ApiParam(value = "版本号,格式为[dynamicVersion]或者[dynamicVersion];[localVersion]", required = true) String version) {
return executeVersionUpdate(serviceId, version);
}
@RequestMapping(path = "/console/version/clear/{serviceId}", method = RequestMethod.POST)
@RequestMapping(path = "/version/clear/{serviceId}", method = RequestMethod.POST)
@ApiOperation(value = "批量清除服务的动态版本", notes = "根据指定的localVersion清除服务的dynamicVersion。如果输入的localVersion不匹配服务的localVersion,则忽略;如果如果输入的localVersion为空,则直接清除服务的dynamicVersion", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> versionClear(@PathVariable(value = "serviceId") @ApiParam(value = "服务名", required = true) String serviceId, @RequestBody(required = false) @ApiParam(value = "版本号,指localVersion,可以为空") String version) {
return executeVersionClear(serviceId, version);
......
......@@ -34,6 +34,7 @@ import com.nepxion.discovery.plugin.framework.event.RuleClearedEvent;
import com.nepxion.discovery.plugin.framework.event.RuleUpdatedEvent;
@RestController
@RequestMapping(path = "/config")
@Api(tags = { "配置接口" })
public class ConfigEndpoint {
@Autowired
......@@ -45,19 +46,19 @@ public class ConfigEndpoint {
@Autowired
private PluginEventWapper pluginEventWapper;
@RequestMapping(path = "/config/update-async", method = RequestMethod.POST)
@RequestMapping(path = "/update-async", method = RequestMethod.POST)
@ApiOperation(value = "异步推送更新规则配置信息", notes = "", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> updateAsync(@RequestBody @ApiParam(value = "规则配置内容,XML格式", required = true) String config) {
return update(config, true);
}
@RequestMapping(path = "/config/update-sync", method = RequestMethod.POST)
@RequestMapping(path = "/update-sync", method = RequestMethod.POST)
@ApiOperation(value = "同步推送更新规则配置信息", notes = "", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> updateSync(@RequestBody @ApiParam(value = "规则配置内容,XML格式", required = true) String config) {
return update(config, false);
}
@RequestMapping(path = "/config/clear", method = RequestMethod.POST)
@RequestMapping(path = "/clear", method = RequestMethod.POST)
@ApiOperation(value = "清除更新的规则配置信息", notes = "", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> clear() {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
......@@ -75,7 +76,7 @@ public class ConfigEndpoint {
return ResponseEntity.ok().body("OK");
}
@RequestMapping(path = "/config/view", method = RequestMethod.GET)
@RequestMapping(path = "/view", method = RequestMethod.GET)
@ApiOperation(value = "查看本地和更新的规则配置信息", notes = "", response = ResponseEntity.class, httpMethod = "GET")
public ResponseEntity<List<String>> view() {
List<String> ruleList = new ArrayList<String>(2);
......
......@@ -37,6 +37,7 @@ import com.nepxion.discovery.common.exception.DiscoveryException;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
@RestController
@RequestMapping(path = "/router")
@Api(tags = { "路由接口" })
public class RouterEndpoint {
@Autowired
......@@ -48,37 +49,37 @@ public class RouterEndpoint {
@Autowired
private DiscoveryClient discoveryClient;
@RequestMapping(path = "/router/services", method = RequestMethod.GET)
@RequestMapping(path = "/services", method = RequestMethod.GET)
@ApiOperation(value = "获取服务注册中心的服务列表", notes = "", response = List.class, httpMethod = "GET")
public List<String> services() {
return getServices();
}
@RequestMapping(path = "/router/instances/{serviceId}", method = RequestMethod.GET)
@RequestMapping(path = "/instances/{serviceId}", method = RequestMethod.GET)
@ApiOperation(value = "获取本地节点可访问其他节点(根据服务名)的实例列表", notes = "", response = List.class, httpMethod = "GET")
public List<ServiceInstance> instances(@PathVariable(value = "serviceId") @ApiParam(value = "目标服务名", required = true) String serviceId) {
return getInstanceList(serviceId);
}
@RequestMapping(path = "/router/info", method = RequestMethod.GET)
@RequestMapping(path = "/info", method = RequestMethod.GET)
@ApiOperation(value = "获取本地节点信息", notes = "获取当前节点的简单信息", response = RouterEntity.class, httpMethod = "GET")
public RouterEntity info() {
return getRouterEntity();
}
@RequestMapping(path = "/router/route/{routeServiceId}", method = RequestMethod.GET)
@RequestMapping(path = "/route/{routeServiceId}", method = RequestMethod.GET)
@ApiOperation(value = "获取本地节点可访问其他节点(根据服务名)的路由信息列表", notes = "", response = List.class, httpMethod = "GET")
public List<RouterEntity> route(@PathVariable(value = "routeServiceId") @ApiParam(value = "目标服务名", required = true) String routeServiceId) {
return getRouterEntityList(routeServiceId);
}
@RequestMapping(path = "/router/route/{routeServiceId}/{routeHost}/{routePort}", method = RequestMethod.GET)
@RequestMapping(path = "/route/{routeServiceId}/{routeHost}/{routePort}", method = RequestMethod.GET)
@ApiOperation(value = "获取指定节点(根据IP和端口)可访问其他节点(根据服务名)的路由信息列表", notes = "", response = List.class, httpMethod = "GET")
public List<RouterEntity> route(@PathVariable(value = "routeServiceId") @ApiParam(value = "目标服务名", required = true) String routeServiceId, @PathVariable(value = "routeHost") @ApiParam(value = "目标服务所在机器的IP地址", required = true) String routeHost, @PathVariable(value = "routePort") @ApiParam(value = "目标服务所在机器的端口号", required = true) int routePort) {
return getRouterEntityList(routeServiceId, routeHost, routePort);
}
@RequestMapping(path = "/router/routes", method = RequestMethod.POST)
@RequestMapping(path = "/routes", method = RequestMethod.POST)
@ApiOperation(value = "获取全路径的路由信息树", notes = "参数按调用服务名的前后次序排列,起始节点的服务名不能加上去。如果多个用“;”分隔,不允许出现空格", response = RouterEntity.class, httpMethod = "POST")
public RouterEntity routes(@RequestBody @ApiParam(value = "例如:service-a;service-b", required = true) String routeServiceIds) {
return routeTree(routeServiceIds);
......
......@@ -33,6 +33,7 @@ import com.nepxion.discovery.plugin.framework.event.VersionClearedEvent;
import com.nepxion.discovery.plugin.framework.event.VersionUpdatedEvent;
@RestController
@RequestMapping(path = "/version")
@Api(tags = { "版本接口" })
public class VersionEndpoint {
@Autowired
......@@ -44,7 +45,7 @@ public class VersionEndpoint {
@Autowired
private PluginEventWapper pluginEventWapper;
@RequestMapping(path = "/version/update", method = RequestMethod.POST)
@RequestMapping(path = "/update", method = RequestMethod.POST)
@ApiOperation(value = "更新服务的动态版本", notes = "根据指定的localVersion更新服务的dynamicVersion。如果输入的localVersion不匹配服务的localVersion,则忽略;如果如果输入的localVersion为空,则直接更新服务的dynamicVersion", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> update(@RequestBody @ApiParam(value = "版本号,格式为[dynamicVersion]或者[dynamicVersion];[localVersion]", required = true) String version) {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
......@@ -73,7 +74,7 @@ public class VersionEndpoint {
return ResponseEntity.ok().body("OK");
}
@RequestMapping(path = "/version/clear", method = RequestMethod.POST)
@RequestMapping(path = "/clear", method = RequestMethod.POST)
@ApiOperation(value = "清除服务的动态版本", notes = "根据指定的localVersion清除服务的dynamicVersion。如果输入的localVersion不匹配服务的localVersion,则忽略;如果如果输入的localVersion为空,则直接清除服务的dynamicVersion", response = ResponseEntity.class, httpMethod = "POST")
public ResponseEntity<?> clear(@RequestBody(required = false) @ApiParam(value = "版本号,指localVersion,可以为空") String version) {
Boolean discoveryControlEnabled = pluginContextAware.isDiscoveryControlEnabled();
......@@ -91,7 +92,7 @@ public class VersionEndpoint {
return ResponseEntity.ok().body("OK");
}
@RequestMapping(path = "/version/view", method = RequestMethod.GET)
@RequestMapping(path = "/view", method = RequestMethod.GET)
@ApiOperation(value = "查看服务的本地版本和动态版本", notes = "", response = ResponseEntity.class, httpMethod = "GET")
public ResponseEntity<List<String>> view() {
List<String> versionList = new ArrayList<String>(2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment