jenkins-java-microservice-demo

  • J0_250230
    了解作者
  • 20KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-28 22:33
    上传日期
jenkins-java-microservice-demo
jenkins-java-microservice-demo-master.zip
内容介绍
package com.rkumarit18.microservices.currencyexchangeservice.resource; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RestController; import com.rkumarit18.microservices.currencyexchangeservice.util.environment.InstanceInformationService; @RestController public class CurrencyExchangeController { private static final Logger LOGGER = LoggerFactory.getLogger(CurrencyExchangeController.class); @Autowired private ExchangeValueRepository repository; @Autowired private InstanceInformationService instanceInformationService; @GetMapping("/") public String imHealthy() { return "{healthy:true}"; } //http://localhost:8000/currency-exchange/from/USD/to/INR @GetMapping("/currency-exchange/from/{from}/to/{to}") public ExchangeValue retrieveExchangeValue(@PathVariable String from, @PathVariable String to, @RequestHeader Map<String, String> headers) { printAllHeaders(headers); ExchangeValue exchangeValue = repository.findByFromAndTo(from, to); LOGGER.info("{} {} {}", from, to, exchangeValue); if (exchangeValue == null) { throw new RuntimeException("Unable to find data to convert " + from + " to " + to); } exchangeValue.setExchangeEnvironmentInfo(instanceInformationService.retrieveInstanceInfo()); return exchangeValue; } private void printAllHeaders(Map<String, String> headers) { headers.forEach((key, value) -> { LOGGER.info(String.format("Header '%s' = %s", key, value)); }); } }
评论
    相关推荐