Wobe Project

Project Requirement:

The server should

  1. Accept a POST request of the below form,
    { "input": "blablabla" }

  2. Response should be the reverse of the "input" string

"albalbalb"

The server should run on a docker container.

How to run

It requires docker, go library, git to run

Steps to run without docker:

  1. Clone the repository under $GOPATH/src/github.com directory
  2. Run go get ./... to install dependencies
  3. 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

Steps to run with docker:

  1. Clone the repository
  2. Run docker build -t wobeproject .
  3. Run docker run -p 6060:8081 wobeproject -env prod
    OR
    Run docker run -d -p 6060:8081 wobeproject -env prod to run in background.

This will keep the server on http://localhost:6060

Test

  1. Using postman application, make "POST" request with one of above urls.
  2. Select "Body" tab then "x-www-form-urlencoded" option.
  3. Put key as "input" and value as any non-palindrome text (to get best results ;-) ) hit "Send"

About project

It has two flags,

  1. -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
  1. -config: To provide config file with path. Default value doesn't work in docker container, so I added working value in Dockerfile