Simple Device API is really simple and concise to show how easy to implement a Restful Service with using Golang.
It uses gin framework for http router.
swag init -g doc.go
BUILD_VERSION=0.0.1
docker build -f build/Dockerfile -t docker.io/simple-device-api:$BUILD_VERSION .
docker run -p 8080:8080 docker.io/simple-device-api:$BUILD_VERSION
DOCKER_USERNAME=""
DOCKER_PASSWORD=""
sh build/build.sh $BUILD_VERSION
GIN_MODE=debug go run cmd/api/main.go --port 8080
http://HOST:PORT/swagger/index.html
curl --location --request POST 'http://127.0.0.1:8080/api/v1/devices' \
--header 'Content-Type: application/json' \
--data-raw '{
"name" : "Iphone",
"brand": "Apple",
"model": "13 Pro Max"
}'
curl --location --request GET 'http://localhost:8080/api/v1/devices/{id}' \
--data-raw ''
curl --location --request DELETE 'http://localhost:8080/api/v1/devices/{id}' \
--data-raw ''