Install MongoDB
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/
Install the Driver
go get -u gopkg.in/mgo.v2
go get -u gopkg.in/mgo.v2/bson
Modify the Code the Add Mongo DB Connection
Curl for sending data
curl http://localhost:8080/user/2501
API : http://localhost:8080/user/:id
POST Data
curl -X POST -H "Content-Type: application/json" -d '{"name":"Harish","gender":"male","age":32}' http://localhost:8080/user
where:
-X
is short for --request
= type of request
Specifies the custom request method to use in communicating with server
-H
is short for --header
= Adding Header field
-d
is short for --data
= String data
Delete User
curl -X DELETE -H "Content-Type: application/json" http://localhost:8080/user/3