A simple and bare minimum Rest API developed using Gorilla Mux and MongoDB. Can be used as an template or reference for future Go project involving RestAPIs.
How to start
Make sure you have Go lang installed
Create a .env file in the root directory of the project
Add MONGO_URL = "mongodb+srv://<MONGO_USER>:<MONGO_PASSWORD>@cluster0.jau8n.mongodb.net/<DEFAULT_DATABASE>?retryWrites=true&w=majority" and use your own MONGO_USER, MONGO_PASSWORD and DEFAULT_DATABASE
go mod tidy
go run main.go
API End Points
/person POST - used to add a person to the database, request body should have firstname and lastname
/person/{id} GET - used to retrieve a person from database using id
/person/{id} DELETE - used to delete a person from database using id
/people GET - used to retrieve all records from the people collection
Found Something Broken
If you find something broken or have a suggestion please feel free to open an Issue.