package pl.java.scalatech;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/")
@Slf4j
public class ComputeController {

	private String welcome = "Welcome to Feign";

	@GetMapping("/message/{name}")
	public String add(@PathVariable(value = "name") String name) {

		log.info("Received request from {} for a greeting.", name);

		return welcome + " " + name;
	}

	@PostMapping("/message/{greeting}")
	public void updateGreeting(@PathVariable(value = "greeting") String greeting) {
		welcome = greeting;

		log.info("Greeting update to {}", welcome);
	}
}

@@ -21,16 +21,140 @@
 atech;%0A%0A
+import org.springframework.cloud.client.ServiceInstance;%0Aimport org.springframework.cloud.client.discovery.DiscoveryClient;%0A
 import o
@@ -451,16 +451,107 @@
 roller;%0A
+import org.springframework.web.client.RestTemplate;%0A%0Aimport lombok.RequiredArgsConstructor;
 %0Aimport 
@@ -603,23 +603,27 @@
 Requ
-estMapping(%22/%22)
+iredArgsConstructor
 %0A@Sl
@@ -660,17 +660,20 @@
 ller %7B%0A%0A
-%09
+    
 private 
@@ -709,18 +709,108 @@
 Feign%22;%0A
-%0A%09
+    private final DiscoveryClient client;%0A    private final RestTemplate restTemplate;%0A%0A    
 @GetMapp
@@ -828,25 +828,28 @@
 ge/%7Bname%7D%22)%0A
-%09
+    
 public Strin
@@ -903,108 +903,602 @@
 ) %7B%0A
-%0A%09%09log.info(%22Received request from %7B%7D for a greeting.%22, name);%0A%0A%09%09return welcome + %22 %22 + name;%0A%09%7D%0A%0A%09
+        ServiceInstance localInstance = client.getLocalServiceInstance();       %0A        String url = %22http://nbp-service/nbp/byCode/USD%22;%0A        String response = restTemplate.getForObject(url, String.class);%0A        return welcome + %22 %22 + name + %22  current usd value : %22 + response + %22 %22 + localInstance.getServiceId() + %22:%22 + localInstance.getHost() + %22:%22 + localInstance.getPort();%0A    %7D%0A    %0A  %0A    @RequestMapping(%22/nbp/hello%22)%0A    public String nbp() %7B%0A        String url = %22http://nbp-service/nbp/hello%22;%0A        return restTemplate.getForObject(url, String.class);%0A    %7D%0A        %0A    
 @Pos
@@ -1529,17 +1529,20 @@
 ting%7D%22)%0A
-%09
+    
 public v
@@ -1613,18 +1613,24 @@
 ting) %7B%0A
-%09%09
+        
 welcome 
@@ -1645,11 +1645,16 @@
 ng;%0A
-%0A%09%09
+        
 log.
@@ -1697,9 +1697,12 @@
 e);%0A
-%09
+    
 %7D%0A%7D%0A

Update ComputeController.java