Browse Source

add /hosts/appName and renamed misspelled bootstrapyml

pull/6/head
Spencer Gibb 10 years ago
parent
commit
56f1a365fc
  1. 10
      spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarController.java
  2. 3
      spring-cloud-netflix-sidecar/src/test/resources/application.yml
  3. 7
      spring-cloud-netflix-sidecar/src/test/resources/bootstrap.yml

10
spring-cloud-netflix-sidecar/src/main/java/org/springframework/cloud/netflix/sidecar/SidecarController.java

@ -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>";
} }
} }

3
spring-cloud-netflix-sidecar/src/test/resources/application.yml

@ -15,6 +15,9 @@ eureka:
serviceUrl: serviceUrl:
defaultZone: http://user:password@localhost:8761/eureka/ defaultZone: http://user:password@localhost:8761/eureka/
ribbon:
ServerListRefreshInterval: 5000
endpoints: endpoints:
refresh: refresh:
enabled: true enabled: true

7
spring-cloud-netflix-sidecar/src/test/resources/bootstrap.yml

@ -0,0 +1,7 @@
spring:
#application:
# name: sideCarTest
cloud:
config:
username: user
password: password
Loading…
Cancel
Save