FizzBuzz Service provide a http REST API to resolve FizzBuzz commonly know technical test.
To compile this project you need:
go
installed
If you have glide instal you can run
glide i
Otherwise, you can run
go get ./...
### 2. Build
- For normal use
go build
- For Docker image
GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -a -installsuffix cgo
To run, simply execute it:
./fizzbuzz-api
To display it's usage, simply run:
./fizzbuzz-api -h
Usage of ./fizzbuzz-api:
-port string
HTTP Port
fizzbuzz-api
have several routes available
<!--Curl-->
http://<host>:<port>/fizzbuzz/v1/version
- 200 Ok
HTTP/1.1 200 OK
{"statusCode":0,"version":"0.0.1"}
<!--Curl-->
http://<host>:<port>/fizzbuzz/v1/fizzbuzz?to=<to>&mul1=<mul1>&mul2=<mul2>&word1=<word1>&word2=<word2>
Field | Description |
---|---|
to | limit of the fizzbuzz |
mul1 | first multiple which will be replace by |
mul2 | second multiple which will be replace by |
word1 | word to replace number multiple of |
word2 | word to replace number multiple of |
- 200 OK
HTTP/1.1
{
"Response": [
"1",
"2",
"fizz",
"4",
"buzz",
"fizz",
"7",
"8",
"fizz",
"buzz",
"11",
"fizz",
"13",
"14",
"fizzbuzz"
],
"statusCode": 0
}
- 406 Invalid agurment
HTTP/1.1 406
{
"message": "One argument is missing or wrong format. you need to provide: to (int), mul1 (int), mul2 (int), word1 (string), word2 (string)",
"status": "invalid argument",
"statusCode": 1
}