Giter Site home page Giter Site logo

currency-converter-service's Introduction

Currency Converter Service

A Simple Service demonstrating the use of Netflix Eureka for providing service for currency converter

Service Provider

@EnableEurekaServer
@SpringBootApplication
@RestController
public class CurrencyConverterApp {

private static final Logger log = LoggerFactory.getLogger(CurrencyConverterApp.class);

@Value("${currency_converter_url}")
private String CURRENCY_CONVERTER_URL;

public static void main(String[] args) {
	SpringApplication.run(CurrencyConverterApp.class, args);
}

@RequestMapping(value="convert/{currencyFrom}/{currencyTo}", produces=MediaType.APPLICATION_JSON_VALUE)
@GetMapping
public CurrencyConversion convertCurrency(@PathVariable("currencyFrom") String currencyFrom, 
								@PathVariable("currencyTo") String currencyTo) {
	log.info("Reading conversion from url " + this.CURRENCY_CONVERTER_URL);
	CurrencyConversion currencyConversion = new RestTemplateBuilder().build().getForObject(CURRENCY_CONVERTER_URL.replace("CURRENCY_FROM", currencyFrom).replace("CURRENCY_TO", currencyTo), CurrencyConversion.class);
	return currencyConversion;
}
}

application.yml

api_layer_accesskey: 
currency_converter_url: "http://apilayer.net/api/live?access_key=${api_layer_accesskey}&currencies=CURRENCY_TO&source=CURRENCY_FROM&format=1"
server:
	port: 8761
eureka:
	client:
		registerWithEureka: false
		fetchRegistry: false

Configuration

  1. Create your api access key from http://apilayer.net and copy it for api_layer_accesskey

Payload

Request

Converting USD to CAD http://localhost:8761/convert/USD/CAD

Response

{"source":"USD","timestamp":1524454683,"quotes":{"USDCAD":1.27564}}

currency-converter-service's People

Contributors

royalghost avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.