Commit 6f2e87b6 by Nepxion

增加获取服务列表接口

parent b67c57ec
...@@ -57,6 +57,12 @@ public class RouterController { ...@@ -57,6 +57,12 @@ public class RouterController {
@Autowired @Autowired
private DiscoveryClient discoveryClient; private DiscoveryClient discoveryClient;
@RequestMapping(path = "/services", method = RequestMethod.GET)
@ApiOperation(value = "获取服务注册中心所有服务列表", notes = "", response = List.class, httpMethod = "GET")
public List<String> services() {
return getServices();
}
@RequestMapping(path = "/instances/{serviceId}", method = RequestMethod.GET) @RequestMapping(path = "/instances/{serviceId}", method = RequestMethod.GET)
@ApiOperation(value = "获取本地节点可访问其他节点(根据服务名)的实例列表", notes = "", response = List.class, httpMethod = "GET") @ApiOperation(value = "获取本地节点可访问其他节点(根据服务名)的实例列表", notes = "", response = List.class, httpMethod = "GET")
public List<ServiceInstance> instances(@PathVariable(value = "serviceId") @ApiParam(value = "目标服务名", required = true) String serviceId) { public List<ServiceInstance> instances(@PathVariable(value = "serviceId") @ApiParam(value = "目标服务名", required = true) String serviceId) {
...@@ -87,6 +93,10 @@ public class RouterController { ...@@ -87,6 +93,10 @@ public class RouterController {
return routeTree(routeServiceIds); return routeTree(routeServiceIds);
} }
public List<String> getServices() {
return discoveryClient.getServices();
}
public List<ServiceInstance> getInstanceList(String serviceId) { public List<ServiceInstance> getInstanceList(String serviceId) {
return discoveryClient.getInstances(serviceId); return discoveryClient.getInstances(serviceId);
} }
......
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