This project implements a Go HTTP Server using the standard library. It involves creating a RESTful API with two endpoints, one for fetching data from a provided MongoDB collection and another for Create-Read operations on an in-memory database.
- POST /records
- Gets data from MongoDB collection. Filters are provided through the JSON body:
startDate
,endDate
,minCount
, andmaxCount
. - Example filter JSON request
{ "startDate": "2016-01-26", "endDate": "2018-02-02", "minCount": 2700, "maxCount": 3000 }
- Gets data from MongoDB collection. Filters are provided through the JSON body:
- GET /in-memory?key=:key
- Gets value by key from the in-memory storage. A key is needed as a query param.
- POST /in-memory
- Creates a key-value pair in the in-memory storage. Key and value are provided through the JSON body:
key
, andvalue
. - Example JSON request
{ "key": "a key", "value": "some value" }
- Creates a key-value pair in the in-memory storage. Key and value are provided through the JSON body:
- Configure env variables
cp .env.example .env
Change listenAddr or the MongoDB URI
- Build the application's binary
make build
- Run the application's binary
./bin/app
- Unit Tests