This is hosted on https://golang-mongodb-rest.onrender.com
- Clone
git clone https://github.com/tobiasprima/Golang_MongoDB_REST.git
- Install Dependency
go mod tidy
- To test with Mongodb locally
-create new
.env
file and add:
DATABASE_URI = {YOUR_DATABASE_URI}
-run on localhost
go run main.go
- Test Endpoints on postman
http://localhost:8080/products
http://localhost:8080/products
with body
{
"name": "{PRODUCT_NAME}",
"category": "{PRODUCT_CATEGORY}",
"price": {PRODUCT_PRICE},
"stock": {PRODUCT_STOCK}
}
http://localhost:8080/products/{ID} // copy ID from get/products method
with body
{
"stock": {PRODUCT_STOCK}
}
or
{
"price": {PRODUCT_PRICE}
}
http://localhost:8080/products/{ID} // copy ID from get/products method