FizzBuzz server for generating FizzBuzz terms written in GO.
fizzbuzzd is a REST server with two endpoints.
Install :
- Docker version 17.12.0+
- Go 1.9.2+
go get -u github.com/fkarakas/fizzbuzzd/cmd/fizzbuzzd
- Signed version
docker run -d -p 8080:8080 fkarakas/fizzbuzzd:signed
- Unsigned version (automatically build from github push)
docker run -d -p 8080:8080 fkarakas/fizzbuzzd:latest
-
Set $GOPATH variable to your GO workspace :
export GOPATH=$HOME/go
-
Checkout the project :
git clone [email protected]:fkarakas/fizzbuzzd.git $GOPATH/src/github.com/fkarakas/fizzbuzzd
-
Install dep :
go get -u github.com/golang/dep/cmd/dep
-
Install gomegalinter (for lint checks) :
go get -u gopkg.in/alecthomas/gometalinter.v2
-
Install linters :
$GOPATH/bin/gometalinter.v2 --install
-
run
make
in$GOPATH/src/github.com/fkarakas/fizzbuzzd
run :
make image
Usage of fizzbuzzd:
-port : server binding port (default 8080)
example :
fizzbuzzd -port=8888
fizzbuzzd responds directly to the following endpoints.
/
- returns a 200 OK response with the version number (used for health checks)
GET /api/v1/fizzbuzz/numbers/:number1/:number2/terms/:term1/:term2
- return an 200 OK response : returns an array of strings
-
number1 : first match number
-
number2 : second match number
-
term1 : first replacement string
-
term2 : second replacement string
-
limit (query parameter ..?limit=200) : optional limit parameter for the number of returned terms (default 100)
curl -v -XGET http://localhost:8080/api/v1/fizzbuzz/numbers/2/3/terms/bob/dylan\?limit=123
Response : HTTP CODE 200
{"result" : [...]}
Several kind of tests are available :
-
Unit tests
-
Blackbox tests
Unit tests are used to verify the wanted behaviour of the server.
To run the unit tests : make test
Blackbox tests are used to verify the docker image built. The Blackbox tests simulate external call from a program using fizzbuzzd.
To run the tests : make blackbox-test VERSION=1.0.0
where VERSION
is the container version of fizzbuzzd