This is an API build using golang
, gin
to handle routing and mongodb
as a database.
- Clone this repo into your local directory using following command
git clone git@github.com:UtkarshM-hub/Go_CRUD_API.git
- update the environment variable
MONGODB_URI
in.env
file to your cluster URI. To setup the cluster checkout this site. - If you haven't installed go yet then check the go site to download go
- Run following command
go mod download && go run .
/
/
route creates a post in the data base.- Make a
POST
request tolocalhost:8080
and the structue of request body should be like following
{
"Title":"ENTER_THE_TITLE",
"Article":"ENTER_THE_ARTICLE_DATA",
}
/post/:postId
- This route sends the post as a response
- The METHOD of request is
GET
/update/:postId
- This route updates the post
- The METHOD of request is
UPDATE
- The request body should be like one showed in
/
route
/delete/:postId
- This route is used to delete the post
- The METHOD of request is
DELETE