Skip to content

Instantly share code, notes, and snippets.

@m-tilab
Last active February 26, 2023 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-tilab/d769719c10b2f1ae4b03a6ec341e8061 to your computer and use it in GitHub Desktop.
Save m-tilab/d769719c10b2f1ae4b03a6ec341e8061 to your computer and use it in GitHub Desktop.
@RestController
@RequestMapping("/service")
public class Controller {
private static final Logger logger = LoggerFactory.getLogger(Controller.class);
private RestTemplate restTemplate;
@Value("${spring.application.name}")
private String applicationName;
public Controller(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
@GetMapping("/path1")
public ResponseEntity path1() {
logger.info("Incoming request at {} for request /path1 ", applicationName);
String response = restTemplate.getForObject("http://localhost:8090/service/path2", String.class);
return ResponseEntity.ok("response from /path1 + " + response);
}
@GetMapping("/path2")
public ResponseEntity path2() {
logger.info("Incoming request at {} at /path2", applicationName);
return ResponseEntity.ok("response from /path2 ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment