The backend of a simple blogging platform built with golang.
- JWT Authentication
- MongoDB as a database
- Gin-gonic as a web framework
Creates new user
Request example
{
"username": "exampleUsername",
"email": "example@gmail.com"
"password": "examplePassword"
}
Request to get a JWT token by user credentials
Request example
{
"username": "exampleUsername",
"password": "examplePassword"
}
Response example
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3R1c2VyMSIsImVtYWlsIjoidGVzdGVtYWlsMSIsImV4cCI6MTY2MzE4MzYwN30.DWKK1YCYA-T9ayZqLiRnKcfumf0Idb8XGHtcSRTFIU4"
}
Returns all articles
Response example
[
{
"id": "631f87caa64144284cd8a2d9",
"userId": "5da2d8aae9b63715ddfae856",
"title": "exampleTitle",
"text": "exampleText"
},
...
]
Required bearer token
Creates new article
Request example
{
"title": "exampleTitle",
"text": "exampleText"
}
Returns article by id
Response example
{
"id": "631f87caa64144284cd8a2d9",
"userId": "5da2d8aae9b63715ddfae856",
"title": "exampleTitle",
"text": "exampleText"
}
Required bearer token
Updates article by id
Request example
{
"title": "exampleTitle",
"text": "exampleText"
}
Required bearer token
Deletes article by id