This is an 'Hello World' API.
Mainly built for me to learn Golang.
Using various go modules:
Package handlers is a collection of handlers (aka "HTTP middleware") for use with Go's net/http package (or any framework supporting http.Handler) :
github.com/gorilla/handlers
Package gorilla/mux implements a request router and dispatcher for matching incoming requests to their respective handler :
github.com/gorilla/mux
To run tests
go test main_test.go
To build on local machine
go build main.go
# run ./main or #main.exe
This should also work with docker, you may need to play with Dockerfile
Build it via docker
docker build -t common-base-api .Then run it via docker
docker run -p 8080:8080 common-base-api:latestThen point your browser to see some output:
/hello outputs in plain text
/status returns a JSON object
the example also uses LoggingHandler from the Gorilla modules to output to stdout any response.
Has tests as well, as an example of bringing it together.