gomazon
Getting Started
Start without Docker:
./scripts/start-mariadb.sh
# cd src/gomazon && go run main.go
Build, Start and Stop service using Docker Compose
docker compose build
docker compose up
docker compose down
All API Functions
In this section all API-Functions will be presented with an example call!
GET JWT-Token
Use the Result-Token for all marked API-Functions!
curl --location --request GET 'localhost:8080/createJWT' \
--header 'Content-Type: application/json' \
--data '{
"username": "user",
"isAdmin": true
}'
CREATE PRODUCT (Admin only)
curl --location 'localhost:8080/products' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer INSERT_TOKEN_HERE' \
--data '{
"name": "WirePods",
"description": "Kabellose Kopfhörer",
"price": 130.20
}'
UPDATE PRODUCT (Admin only)
curl --location --request PUT 'localhost:8080/products/1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer INSERT_TOKEN_HERE' \
--data '{
"name": "new Name",
"description": "new Description",
"price": 100.00
}'
DELETE PRODUCT (Admin only)
curl --location --request DELETE 'localhost:8080/products/1' \
--header 'Authorization: Bearer INSERT_TOKEN_HERE'
GET ALL PRODUCTS
curl --location 'localhost:8080/products'
GET SINGLE PRODUCT
curl --location 'localhost:8080/products/1'
Health Check
Function tests if the service is running.
curl --location 'localhost:8080/health'