sudo apt install snapd
sudo snap install go
# Install dependencies
go build
# Start the server linux
./golangApiRest
GOOGLE_IAM_KEY = "./security/bigquery_key.json"
BIGQUERY_PROJECT_ID = "project-123456789"
GOOGLE_CHAT_WEBHOOK = "https://chat.googleapis.com/v1/spaces/AAAAgOxrNhU/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=zk3322S04V0WdHW9y_4Zsg62CUZP9HvIvy0000uJ1qo%3D"
POSTGRESQL_HOST = "localhost"
POSTGRESQL_USER = "postgres"
POSTGRESQL_PASSWORD = "postgres"
POSTGRESQL_DBNAME = "golangApiRest"
POSTGRESQL_PORT = "5432"
Locate: Biquery
Name: users
AutoMigrate: false
Column | Type | Compilate |
---|---|---|
id | STRING | NULLABLE |
status | STRING | NULLABLE |
name | STRING | NULLABLE |
phone | STRING | NULLABLE |
created_at | DATETIME | NULLABLE |
updated_at | DATETIME | NULLABLE |
Locate: Postgresql
Name: products
AutoMigrate: true
Soft Delete: deleted_at
Column | Type |
---|---|
id | BIGINT |
name | TEXT |
value | NUMERIC |
created_at | TIMESTAMP |
updated_at | TIMESTAMP |
deleted_at | TIMESTAMP |
Request
GET http://localhost:8001/ping
Response
### Status code: 200
{
"msg": "pong"
}
Request
POST http://localhost:8001/user
Content-Type: application/json
{
"name": "Testenildos",
"phone" : "5562981919191",
"status": "Registred"
}
Response
### Status code: 201
{
"id": "b11b1522-cb7c-48b8-9b35-27ec3a343e34",
"name": "Testenildos",
"phone": "5562981919191",
"status": "Registred",
"created_at": "2022-09-24T23:01:15.748503488",
"updated_at": "2022-09-24T23:01:15.748503488"
}
Request
GET http://localhost:8001/user/:id
Response
### Status code: 200
[
{
"id": "c8b948cd-4172-40a1-924a-fe815214f659",
"name": "Testenildfffffo",
"phone": "5562981921119191",
"status": "Registr11ed",
"created_at": "2022-09-22T18:31:17",
"updated_at": "2022-09-22T18:31:17"
}
]
Request
GET http://localhost:8001/user
Response
### Status code: 200
[
{
"id": "c8b948cd-4172-40a1-924a-fe815214f659",
"name": "Testenildfffffo",
"phone": "5562981921119191",
"status": "Registr11ed",
"created_at": "2022-09-22T18:31:17",
"updated_at": "2022-09-22T18:31:17"
},
{
"id": "ac668339-beee-46e6-87c5-8a482e5d9d26",
"name": "Testenildo",
"phone": "5562981919191",
"status": "Registred",
"created_at": "2022-09-22T18:31:22",
"updated_at": "2022-09-22T18:31:22"
},
{
"id": "b11b1522-cb7c-48b8-9b35-27ec3a343e34",
"name": "Testenildos",
"phone": "5562981919191",
"status": "Registred",
"created_at": "2022-09-24T23:01:15",
"updated_at": "2022-09-24T23:01:15"
}
]
Request
PUT http://localhost:8001/user/:id
Content-Type: application/json
{
"status": "Processed"
}
Response
### Status code: 200
Request
DELETE http://localhost:8001/user/:id
Response
### Status code: 200
Request
POST http://localhost:8001/product
Content-Type: application/json
{
"name": "balinha",
"value": 0.11
}
Response
### Status code: 201
{
"id": 1,
"name": "balinha",
"value": 0.11,
"created_at": "2022-09-25T19:49:19.758414735-03:00",
"updated_at": "2022-09-25T19:49:19.758414735-03:00"
}
Request
GET http://localhost:8001/product/:id
Response
### Status code: 200
[
{
"id": 1,
"name": "balinha",
"value": 0.11,
"created_at": "2022-09-25T19:49:19.758414-03:00",
"updated_at": "2022-09-25T19:49:19.758414-03:00"
}
]
Request
GET http://localhost:8001/product
Response
### Status code: 200
[
{
"id": 1,
"name": "balinha",
"value": 0.11,
"created_at": "2022-09-25T19:49:19.758414-03:00",
"updated_at": "2022-09-25T19:49:19.758414-03:00"
},
{
"id": 2,
"name": "Bola",
"value": 10.5,
"created_at": "2022-09-25T19:52:01.388815-03:00",
"updated_at": "2022-09-25T19:52:01.388815-03:00"
}
]
Request
PUT http://localhost:8001/product/:id
Content-Type: application/json
{
"value": 11.00
}
Response
### Status code: 200
{
"id": 2,
"name": "Bola",
"value": 11,
"created_at": "2022-09-25T19:52:01.388815-03:00",
"updated_at": "2022-09-25T19:53:54.586532334-03:00"
}
Request
DELETE http://localhost:8001/product/:id
Response
### Status code: 200