RESTful API based on Go, PostgreSQL and Docker
https://localhost:8000/docs/index.html
You can install Docker there
You can install Golang there
You can install PostgreSQL there
-
Clone repository
-
In main directory:
With Docker: for Windows users:docker-compose build docker-compose up -d postgresdb docker-compose up -d app
for Linux users:
sudo docker compose build sudo docker compose up -d postgresdb sudo docker compose up -d app
Without Docker: Set PostgreSQL in pgAdmin (see in env file (.env)) and
go build //for windows backendproj.exe //for linux ./backendproj
- User (example):
{
"id": 906,
"username": "Andrew",
"password": "$2a$14$kv/sGmTWIlNYocbZqd88GuRsrOtKrs9bBFMM7N7HRNZ.qPxF.b.GG", //bcrypt hash
"created_at": "2023-09-24T17:13:42Z",
"updated_at": "2023-09-27T11:10:23Z"
}
- Booking (example):
{
"id": 1021,
"user_id": 906,
"end_time": "2023-10-01T14:30:00Z",
"start_time": "2023-10-01T12:00:00Z",
"comment": "I may be a little late"
}
-
/user/{id} [get]
Get User by id -
/user [post]
Create User from postForm: username, password -
/user/{user_id} [delete]
Delete User and its bookings by user_id -
/user/{id} [put]
Update User data (optional: username, password) by id (set new timestamp in update_at) -
/booking [get]
Get all bookings ordered by id -
/booking/{id} [get]
Get Booking by id (optional: set limit, page(required limit), offset(required limit) in params) -
/booking [post]
Create User from postForm: user_id, start_time, end_time, comment(optional) -
/booking/{id} [delete]
Delete Booking by id -
/booking/{id} [put]
Update Booking data (optional: start_time, end_time, comments) by id