|
|
@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.cloud.client.ServiceInstance; |
|
|
|
import org.springframework.cloud.client.ServiceInstance; |
|
|
|
import org.springframework.cloud.client.discovery.DiscoveryClient; |
|
|
|
import org.springframework.cloud.client.discovery.DiscoveryClient; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
@ -27,8 +28,13 @@ public class SidecarController { |
|
|
|
return "OK"; |
|
|
|
return "OK"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/hosts/{appName}") |
|
|
|
|
|
|
|
public List<ServiceInstance> hosts(@PathVariable("appName") String appName) { |
|
|
|
|
|
|
|
return hosts2(appName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/hosts") |
|
|
|
@RequestMapping("/hosts") |
|
|
|
public List<ServiceInstance> hosts(@RequestParam("appName") String appName) { |
|
|
|
public List<ServiceInstance> hosts2(@RequestParam("appName") String appName) { |
|
|
|
List<ServiceInstance> instances = discovery.getInstances(appName); |
|
|
|
List<ServiceInstance> instances = discovery.getInstances(appName); |
|
|
|
return instances; |
|
|
|
return instances; |
|
|
|
} |
|
|
|
} |
|
|
@ -38,7 +44,7 @@ public class SidecarController { |
|
|
|
return "<head><title>Sidecar</title></head><body>\n" + |
|
|
|
return "<head><title>Sidecar</title></head><body>\n" + |
|
|
|
"<a href='/ping'>ping</a><br/>\n" + |
|
|
|
"<a href='/ping'>ping</a><br/>\n" + |
|
|
|
"<a href='/health'>health</a><br/>\n" + |
|
|
|
"<a href='/health'>health</a><br/>\n" + |
|
|
|
"<a href='/hosts?appName="+appName+"'>hosts?appName="+appName+"</a><br/>\n" + |
|
|
|
"<a href='/hosts/"+appName+"'>hosts/"+appName+"</a><br/>\n" + |
|
|
|
"</body>"; |
|
|
|
"</body>"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|