|
|
|
@ -2,11 +2,7 @@ package com.alibaba.cloud.examples;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
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.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.cloud.examples.ConsumerApplication.EchoService;
|
|
|
|
@ -44,53 +40,53 @@ public class TestController {
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/echo-rest/{str}", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/echo-rest/{str}")
|
|
|
|
|
public String rest(@PathVariable String str) {
|
|
|
|
|
return restTemplate.getForObject("http://service-provider/echo/" + str,
|
|
|
|
|
String.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/index", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/index")
|
|
|
|
|
public String index() {
|
|
|
|
|
return restTemplate1.getForObject("http://service-provider", String.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/test", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/test")
|
|
|
|
|
public String test() {
|
|
|
|
|
return restTemplate1.getForObject("http://service-provider/test", String.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/sleep", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/sleep")
|
|
|
|
|
public String sleep() {
|
|
|
|
|
return restTemplate1.getForObject("http://service-provider/sleep", String.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/notFound-feign", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/notFound-feign")
|
|
|
|
|
public String notFound() {
|
|
|
|
|
return echoService.notFound();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/divide-feign", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/divide-feign")
|
|
|
|
|
public String divide(@RequestParam Integer a, @RequestParam Integer b) {
|
|
|
|
|
return echoService.divide(a, b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/divide-feign2", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/divide-feign2")
|
|
|
|
|
public String divide(@RequestParam Integer a) {
|
|
|
|
|
return echoService.divide(a);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/echo-feign/{str}", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/echo-feign/{str}")
|
|
|
|
|
public String feign(@PathVariable String str) {
|
|
|
|
|
return echoService.echo(str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/services/{service}", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/services/{service}")
|
|
|
|
|
public Object client(@PathVariable String service) {
|
|
|
|
|
return discoveryClient.getInstances(service);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/services", method = RequestMethod.GET)
|
|
|
|
|
@GetMapping(value = "/services")
|
|
|
|
|
public Object services() {
|
|
|
|
|
return discoveryClient.getServices();
|
|
|
|
|
}
|
|
|
|
|