Created
June 27, 2017 20:12
-
-
Save mkheck/d70f0fa9d0004e3942deec8b28bf3c7f to your computer and use it in GitHub Desktop.
This file contains 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
package com.example.szconsumerservice; | |
import lombok.extern.java.Log; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.web.client.RestOperations; | |
import org.springframework.web.client.RestTemplate; | |
@SpringBootApplication | |
public class SzConsumerServiceApplication { | |
@Bean | |
RestOperations restOperations() { | |
return new RestTemplate(); | |
} | |
public static void main(String[] args) { | |
SpringApplication.run(SzConsumerServiceApplication.class, args); | |
} | |
} | |
@Log | |
@RestController | |
class ConsumerController { | |
private final RestOperations restOperations; | |
ConsumerController(RestOperations restOperations) { | |
this.restOperations = restOperations; | |
} | |
@GetMapping("/greet") | |
public String getGreeting() { | |
log.info("Logging GET request to /greet for " + this.getClass().toString()); | |
return restOperations.getForObject("http://localhost:8080/hi", String.class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment