This is a minimal key/value microservice allowing to store and retrieve a key/value pairs in MongoDB
# clone the repository
git clone https://github.com/telemac/mongo-minimal-microservice.git
cd mongo-minimal-microservice
# Launch a MongoDB demo database in a docker container
docker-compose up -d
go build -o mongo-minimal-microservice cmd/main.go
docker run --rm --name golang -t -v "$PWD:/src" golang:1.13.3-buster sh -c "cd /src && go build -o mongo-minimal-microservice cmd/main.go"
# get the command line options
./mongo-minimal-microservice -h
# run the demo microservice with default options
./mongo-minimal-microservice
Open another terminal and insert and request records
# insert a key/value pair
curl -X POST -d'{"k":"name","v":"Alexandre"}' localhost:9090/kv
# get all key/value pairs
curl localhost:9090/kv