Merge pull request #3176 from Sgitario/master
BAEL-1174: A Quick Guide to Spring Cloud Consul: Fix Ribbon client
This commit is contained in:
commit
bd0bba04d4
|
@ -8,7 +8,10 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@ -36,6 +39,11 @@ public class DiscoveryClientApplication {
|
||||||
return "pong";
|
return "pong";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/my-health-check")
|
||||||
|
public ResponseEntity<String> myCustomCheck() {
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
public URI serviceUrl() {
|
public URI serviceUrl() {
|
||||||
return discoveryClient.getInstances("myApp")
|
return discoveryClient.getInstances("myApp")
|
||||||
.stream()
|
.stream()
|
||||||
|
|
|
@ -5,6 +5,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -33,6 +35,11 @@ public class RibbonClientApplication {
|
||||||
return "pong";
|
return "pong";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/my-health-check")
|
||||||
|
public ResponseEntity<String> myCustomCheck() {
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new SpringApplicationBuilder(RibbonClientApplication.class).web(true)
|
new SpringApplicationBuilder(RibbonClientApplication.class).web(true)
|
||||||
.run(args);
|
.run(args);
|
||||||
|
|
Loading…
Reference in New Issue