Add README, removing wrong logger dependency
This commit is contained in:
37
README.md
Normal file
37
README.md
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
It will launch the fizz-buzz endpoint listenning on `*:8080`.
|
||||||
|
|
||||||
|
Then, you can query the server via http, providing the required parameters:
|
||||||
|
|
||||||
|
$ curl 'http://localhost:8080/?string1=a&string2=b&int1=3&int2=2&limit=14'
|
||||||
|
|
||||||
|
fizzbuzz-lbc expects 5 parameters:
|
||||||
|
|
||||||
|
- `string1`: the first string
|
||||||
|
- `string2`: the second string
|
||||||
|
- `int1`: the first integer
|
||||||
|
- `int2`: the second integer
|
||||||
|
- `limit`: the limit
|
||||||
@@ -3,11 +3,10 @@ package fizzbuzz
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/wallix/awless/logger"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server represents an instance of a fizzbuzz server
|
// Server represents an instance of a fizzbuzz server
|
||||||
@@ -47,7 +46,7 @@ func (s *Server) handleFizzBuzz(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err = json.NewEncoder(w).Encode(in.generateFizzbuzz()); err != nil {
|
if err = json.NewEncoder(w).Encode(in.generateFizzbuzz()); err != nil {
|
||||||
logger.Errorf("error while encoding '%#v': %s", in, err.Error())
|
log.Printf("error while encoding '%#v': %s", in, err.Error())
|
||||||
http.Error(w, "encoding problem", http.StatusInternalServerError)
|
http.Error(w, "encoding problem", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user