Currency exchange rate converter service
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Godeps
common
provider/converter
service/converter
vendor/github.com
.gitignore
.travis.yml
Dockerfile
LICENSE
Procfile
README.md
main.go

README.md

go-currency

Build Status Go Report Card

go-currency is a currency exchange rate converter service written in Go. By default uses Fixer.io as exchange rate provider.

Online version (heroku)

Heroku - go-currency

Install & Run

This project assumes that you are working in a standard Go workspace, as described in http://golang.org/doc/code.html.

Bash

# Go to your $GOPATH
$ cd $GOPATH

# Download and build
$ go get github.com/floreks/go-currency

# Run it
$ ./bin/go-currency --port <OPTIONAL_PORT>

Docker

Container can be stopped using CTRL+C.

Building own image

# Go to your $GOPATH
$ cd $GOPATH

# Download and build
$ go get github.com/floreks/go-currency

$ cd $GOPATH/src/github.com/floreks/go-currency

# Build docker image
$ docker build -t go-currency .

# Run our service
$ docker run -p 8080:8080 go-currency

DockerHub image

Check it out on docker hub: go-currency

In order to run it just type in your console:

$ docker run -p 8080:8080 floreks/go-currency

Usage

Let's assume that the application is running on localhost:8080. Service can produce XML/JSON output based on request header.

XML output

Exchange rates for 200 SEK

curl -H "Accept: application/xml, */*" "http://localhost:8080/convert?amount=200&currency=SEK"

JSON output

Exchange rates for 200 SEK

curl "http://localhost:8080/convert?amount=200&currency=SEK"

Offline provider

Additionally if Fixer.io is offline we can fallback to local provider that uses exchange rates from 31.10.2016. It supports only 3 base currencies: EUR, PLN, USD.

curl "http://localhost:8080/convert?amount=200&currency=PLN&provider=local"

Running tests

Go to your project directory and run:

$ go test ./...