Go Fiber Example API is a RESTful API built using the Fiber web framework.
- Clone the repository:
git clone https://github.com/yusuftalhaklc/go-fiber-gorm-pgsql.git
- Navigate to the project directory:
cd go-fiber-gorm-pgsql
- Install the dependencies:
go mod tidy
- Start the API server:
go run main.go
It is currently running on localhost port 8080. Postman Collection
- Endpoint:
/api/user
- Method:
GET
- Authorization: Token
- Description: Get all users.
- Endpoint:
/api/user/:id
- Method:
GET
- Description: Get a single user by ID.
- Endpoint:
/api/user/login
- Method:
POST
- Description: Login.
- Endpoint:
/api/user
- Method:
POST
- Description: Create a new user.
- Endpoint:
/api/user/:id
- Method:
PUT
- Description: Update an existing user by ID.
- Endpoint:
/api/user/:id
- Method:
DELETE
- Description: Delete a user by ID.
- Request Body
{
"username":"username",
"email": "[email protected]",
"password":"password123"
}
- Response
{
"data": [
{
"CreatedAt": "2023-06-26T11:46:46.46791+03:00",
"UpdatedAt": "2023-06-26T11:46:46.46791+03:00",
"DeletedAt": null,
"ID": "f907c118-b2df-4920-9f04-6d13c96b355c",
"username": "username",
"email": "[email protected]",
"password": "4ee1d94f2cc476688105a776dcc6d36c32ad00aa68b901baeff71b115676f45d"
},
{
"CreatedAt": "2023-06-26T11:46:52.784047+03:00",
"UpdatedAt": "2023-06-26T11:46:52.784047+03:00",
"DeletedAt": null,
"ID": "2e723e10-0a12-42ee-ac46-a9e268ebb66e",
"username": "username2",
"email": "[email protected]",
"password": "7772448cf067ba366d81d3133feb61e449e65e3e6d516371cb2754e329c691b4"
}
],
"message": "Users Found",
"status": "sucess"
}
- Request
POST /api/user/login
{
"username":"username",
"password":"password123"
}
- Response
{
"message": "Login succesfuly",
"status": "success",
"token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODc3ODE3MzksImlkIjoiZDk3MmE0NWEtNTNiZC00ODgwLTgwODktZDk1NDlkMzRhMzQ4IiwidXNlcm5hbWUiOiJ1c2VybmFtZTEyMyJ9.TjRCOKgQwGylLzOQ0kG3Qrk1ySOGZnGfa8SWPZHV-ZXNfucJcBV9Y4ysirFj2GXyxH1ybgZ6BME50E3HrsaPIA"
}
- Request
GET /api/users
- Response
{
"data": [
{
"CreatedAt": "2023-06-26T11:33:44.674928+03:00",
"UpdatedAt": "2023-06-26T11:33:44.674928+03:00",
"DeletedAt": null,
"ID": "f907c118-b2df-4920-9f04-6d13c96b355c",
"username": "username",
"email": "[email protected]",
"password": "4ee1d94f2cc476688105a776dcc6d36c32ad00aa68b901baeff71b115676f45d"
}
],
"message": "Users Found",
"status": "sucess"
}
- Request
GET /api/user/f907c118-b2df-4920-9f04-6d13c96b355c
- Response
{
"data": {
"CreatedAt": "2023-06-26T11:33:44.674928+03:00",
"UpdatedAt": "2023-06-26T11:33:44.674928+03:00",
"DeletedAt": null,
"ID": "f907c118-b2df-4920-9f04-6d13c96b355c",
"username": "username",
"email": "[email protected]",
"password": "4ee1d94f2cc476688105a776dcc6d36c32ad00aa68b901baeff71b115676f45d"
},
"message": "User Found",
"status": "success"
}
- Request
PUT /api/user/f907c118-b2df-4920-9f04-6d13c96b355c
{
"username" : "yusuftalhaklc"
}
- Response
{
"data": {
"CreatedAt": "2023-06-26T11:33:44.674928+03:00",
"UpdatedAt": "2023-06-26T11:39:07.7508237+03:00",
"DeletedAt": null,
"ID": "f907c118-b2df-4920-9f04-6d13c96b355c",
"username": "yusuftalhaklc",
"email": "[email protected]",
"password": "4ee1d94f2cc476688105a776dcc6d36c32ad00aa68b901baeff71b115676f45d"
},
"message": "users Found",
"status": "success"
}
- Request
DELETE /api/user/f907c118-b2df-4920-9f04-6d13c96b355c
- Response
{
"message": "User deleted",
"status": "success"
}