|
|
|
|
# LBC's Fizzbuzz server
|
|
|
|
|
|
|
|
|
|
This repository implements a basic LBC's Fizz-Buzz API server.
|
|
|
|
|
It exposes a unique endpoint (`/`) returning the LBC's Fizz-Buzz list.
|
|
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
|
|
First, you need to [install go](https://golang.org/doc/install) and set your `$GOPATH` env variable.
|
|
|
|
|
|
|
|
|
|
Then, you can download, build and install fizzbuzz-lbc, by running:
|
|
|
|
|
|
|
|
|
|
$ go get dev.fxaguessy.fr/fx/fizzbuzz-lbc
|
|
|
|
|
|
|
|
|
|
## Test
|
|
|
|
|
|
|
|
|
|
$ cd $GOPATH/src/dev.fxaguessy.fr/fx/fizzbuzz-lbc
|
|
|
|
|
$ go test ./...
|
|
|
|
|
|
|
|
|
|
## Run
|
|
|
|
|
|
|
|
|
|
If you installed fizzbuzz-lbc using `go get` or with `go install`, you can run it with
|
|
|
|
|
|
|
|
|
|
$ $GOPATH/bin/fizzbuzz-lbc
|
|
|
|
|
|
|
|
|
|
or you can run it in the source folder by running
|
|
|
|
|
|
|
|
|
|
$ go run main.go
|
|
|
|
|
|
|
|
|
|
`fizzbuzz-lbc` will listen by default on `*:8080`, but you can specify the host and port by using the `-hostport flag`, for example:
|
|
|
|
|
|
|
|
|
|
$ ./fizzbuzz-lbc -hostport 127.0.0.1:8000
|
|
|
|
|
|
|
|
|
|
Then, you can query the server via http, providing the required parameters:
|
|
|
|
|
|
|
|
|
|
$ curl 'http://localhost:8080/?string1=fizz&string2=buzz&int1=3&int2=5&limit=100'
|
|
|
|
|
|
|
|
|
|
fizzbuzz-lbc expects 5 parameters:
|
|
|
|
|
|
|
|
|
|
- `string1`: the first string
|
|
|
|
|
- `string2`: the second string
|
|
|
|
|
- `int1`: the first integer
|
|
|
|
|
- `int2`: the second integer
|
|
|
|
|
- `limit`: the limit
|