This is the simple blog api in which user have to create account and then login to create a blog post and can comment to anyone's blog post.
-
POST -
To create an account.
To create a blog post.
To create comment on post.
To login.
-
GET -
To get the list of person.
To get the list of blog post.
To get the list of comments.
-
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://gitlab.com/htp22/mashiyatblog.git
-
This will take some time because it downloads this project and downloads all the imported dependencies.
-
Now,
cd mashiyatblog
-
Now, run a mogodb server on your local machine.
-
Run
go build
to build the go project in a executable file.
(Testing can be done using POSTMAN)
-
Create an account > POST
"http://localhost:8000/person"
> Enter three values in Body (raw)firstname, lastname, email, password
. -
Login > POST
"http://localhost:8000/login"
> Enter two values in Body (raw)email password
. -
Create a blog > POST
"http://localhost:8000/blogpage"
> Enter three key values in Body (raw)title, description, user_id
. -
Get all blogs > GET
"http://localhost:8000/blogpage"
> This get an array of all blogs. -
Get a specific blog > GET
"http://localhost:8000/person/{_id}"
> This gets the object of the specified blog id.