go-store-api
Build
go build -o dist/app
Start
Application uses 8080 port
./dist/app
Authorization (for protected endpoints)
Basic auth with credentials
Username: admin
Password: password
API methods
GET /goods
Successful response (code 200):
{
"data": [
{
"id": 1,
"name": "foo",
"price": "10",
"count": 22
},
{
"id": 2,
"name": "bar",
"price": "20",
"count": 0
}
],
"status": "ok"
}
GET /goods/:id
Successful response (code 200):
{
"data": {
"id": 1,
"name": "foo",
"price": "10",
"count": 22
},
"status": "ok"
}
Not found response (code 404):
{
"error": "not found",
"status": "error"
}
Protected API methods
POST /goods
Body:
{
"name": "good",
"price": "10",
"count": 22
}
Successful response (code 201):
{
"data": {
"id": 1,
"name": "foo",
"price": "10",
"count": 22
},
"status": "ok"
}