This is a basic blog api designed using golang.
- Install Golang on your machine.
1.1. Make sure you have GOPATH set in your environment variables.
1.2. Ensure it using
echo %GOPATH%
- Get this project by this command:
go get -u https://github.com/astro_coder/capture-life-api.git
- This will take some time because it downloads this project and downloads all the imported dependencies.
- Now,
cd capture-life-api
- Now, run a mogodb server on your local machine, which by default runs on port :27017.
- Run
go build
to build the go project in a executable file. - Run the executable by just typing
capture-life-api
- If the above command prompt Server running @5000, then you are good to go.
Testing can be done using POSTMAN
- Create a blog > POST "/api/blogs/create" > Enter three key values in Body (x-www-form-urlencoded)
title, content, author, timestamp
- Get all blogs > GET "/api/blogs" > This get an array of all blogs.
- Get a specific blog > GET "/api/blog/{_id}" > This gets the object of the specified blog id.
- Delete a specific blog > DELETE "/api/blog/{_id}" > This deletes the blog identified by the specified id.
- Update a specific blog > PUT "/api/blog/{_id}" > This updates the specified blog. This also requires three key values in Body (x-www-form-urlencoded)
title, content, author, timestamp
- Create a blog > POST "/api/comments/create" > Enter three key values in Body (x-www-form-urlencoded)
title, content, author, timestamp, blog_id, replyto
- Get all blogs > GET "/api/comments" > This get an array of all comments.
- Get a specific blog > GET "/api/comment/{_id}" > This gets the object of the specified comment id.
- Delete a specific blog > DELETE "/api/comment/{blog_id}" > This deletes the comment identified by the specified blog id.
- Update a specific blog > PUT "/api/comment/{_id}" > This updates the specified comment. This also requires key values in Body (x-www-form-urlencoded)
title, content, author, timestamp, blog_id, replyto