You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hystrix-catfact/src/main/java/com/example/demo/FactController.java

27 lines
795 B

package com.example.demo;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/cat")
public class FactController {
@GetMapping
@RequestMapping("/fact")
public String getFact() {
HystrixCommand.Setter config = HystrixCommand
.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey("catfact"));
String fact = new RemoteServiceFactCommand(config, new CatApi()).execute();
if(fact == null){
return "no success";
}
return fact;
}
}