add /hosts/appName and renamed misspelled bootstrapyml
This commit is contained in:
@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -27,8 +28,13 @@ public class SidecarController {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
@RequestMapping("/hosts/{appName}")
|
||||
public List<ServiceInstance> hosts(@PathVariable("appName") String appName) {
|
||||
return hosts2(appName);
|
||||
}
|
||||
|
||||
@RequestMapping("/hosts")
|
||||
public List<ServiceInstance> hosts(@RequestParam("appName") String appName) {
|
||||
public List<ServiceInstance> hosts2(@RequestParam("appName") String appName) {
|
||||
List<ServiceInstance> instances = discovery.getInstances(appName);
|
||||
return instances;
|
||||
}
|
||||
@@ -38,7 +44,7 @@ public class SidecarController {
|
||||
return "<head><title>Sidecar</title></head><body>\n" +
|
||||
"<a href='/ping'>ping</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>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ eureka:
|
||||
serviceUrl:
|
||||
defaultZone: http://user:password@localhost:8761/eureka/
|
||||
|
||||
ribbon:
|
||||
ServerListRefreshInterval: 5000
|
||||
|
||||
endpoints:
|
||||
refresh:
|
||||
enabled: true
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
spring:
|
||||
#application:
|
||||
# name: sideCarTest
|
||||
cloud:
|
||||
config:
|
||||
username: user
|
||||
password: password
|
||||
Reference in New Issue
Block a user