The server should
-
Accept a POST request of the below form,
{ "input": "blablabla" } -
Response should be the reverse of the "input" string
"albalbalb"
The server should run on a docker container.
It requires docker, go library, git to run
- Clone the repository under
$GOPATH/src/github.com
directory - Run
go get ./...
to install dependencies - Run
go run main.go -env prod
NOTE: flags for -env are "prod", "dev" and "debug"
This will keep the server on http://localhost:8081
- Clone the repository
- Run
docker build -t wobeproject .
- Run
docker run -p 6060:8081 wobeproject -env prod
OR
Rundocker run -d -p 6060:8081 wobeproject -env prod
to run in background.
This will keep the server on http://localhost:6060
- Using postman application, make "POST" request with one of above urls.
- Select "Body" tab then "x-www-form-urlencoded" option.
- Put key as "input" and value as any non-palindrome text (to get best results ;-) ) hit "Send"
It has two flags,
- -env: environment of project. It pulls environment specific configuration. It supports "dev", "debug" and "prod" as values. Following table shows the description and some of values from
config.toml
file.
dev | debug | prod | |
tracelevel | infolevel, warnlevel, errorlevel, paniclevel |
infolevel, warnlevel, errorlevel, paniclevel, debuglevel |
infolevel, warnlevel, errorlevel, paniclevel |
stacktrace | false for all levels | false for all levels | true for only errors and panics |
erroroutput (meant for writing logs in file ONLY if provided in code) | true for all levels | true for warn, panic,debug | false for all |
caller (line number of caller and filename) | true for all | true for warn, error,panic,debug | false for all |
caller_skip (skip line no. of caller) | Its not stable so please don't change | Its not stable so please don't change | Its not stable so please don't change |
- -config: To provide config file with path. Default value doesn't work in docker container, so I added working value in Dockerfile