Go restful api build for learning go using fiber and mongodb
Request :
- Method : POST
- Endpoint :
/api/signup
- Header :
- Content-Type: application/json
- Accept: application/json
- Body :
{
"username": "string",
"password": "string",
"email": "string",
"phone": "string"
}
Response :
{
"code": "int",
"status": "string",
"data": {
"id": "string",
"username": "string",
"password": "string",
"email": "string",
"phone": "string"
}
}
Request :
- Method : POST
- Endpoint :
/api/login
- Header :
- Content-Type: application/json
- Accept: application/json
- Body :
{
"username": "string",
"password": "string"
}
Response :
{
"code": "int",
"status": "string",
"data": {
"access_token": "string",
"user": {
"id": "string",
"username": "string",
"email": "string",
"phone": "string"
}
}
}
Request :
- Method : POST
- Endpoint :
/api/products
- Header :
- Authorization: Bearer xxxxx
- Content-Type: application/json
- Accept: application/json
- Body :
{
"name": "string",
"price": "int64",
"quantity": "int32"
}
Response :
{
"code": "int",
"status": "string",
"data": {
"id": "string",
"name": "string",
"price": "int64",
"quantity": "int32"
}
}
Request :
- Method : PUT
- Endpoint :
/api/products
- Header :
- Authorization: Bearer xxxxx
- Content-Type: application/json
- Accept: application/json
- Body :
{
"id": "string",
"name": "string",
"price": "int64",
"quantity": "int32"
}
Response :
{
"code": "int",
"status": "string",
"data": {
"id": "string",
"name": "string",
"price": "int64",
"quantity": "int32"
}
}
Request :
- Method : GET
- Endpoint :
/api/products/:id
- Header :
- Authorization: Bearer xxxxx
- Content-Type: application/json
- Accept: application/json
Response :
{
"code": "int",
"status": "string",
"data": {
"id": "string",
"name": "string",
"price": "int64",
"quantity": "int32"
}
}
Request :
- Method : GET
- Endpoint :
/api/products
- Header :
- Authorization: Bearer xxxxx
- Content-Type: application/json
- Accept: application/json
Response :
{
"code": "int",
"status": "string",
"data": [
{
"id": "string",
"name": "string",
"price": "int64",
"quantity": "int32"
},
{
"id": "string",
"name": "string",
"price": "int64",
"quantity": "int32"
}
]
}
Request :
- Method : DELETE
- Endpoint :
/api/products/:id
- Header :
- Authorization: Bearer xxxxx
- Content-Type: application/json
- Accept: application/json
Response :
{
"code": "int",
"status": "string",
"data": "string"
}