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