Last active
February 26, 2023 10:52
-
-
Save m-tilab/d769719c10b2f1ae4b03a6ec341e8061 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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