This is a REST API built for IOT project using Golang, Gin and Gorm.
HOST=<Hostname>
DBPORT=<PostgreSQL Server Port>
DBUSER=<Database User Name>
DBNAME=<Database Name>
DBPASSWORD=<Database Password>
EMAIL_ADDR=<From Email>
EMAIL_PSWD=<From Email Password>
EMAIL_HOST=<SMTP Host>
EMAIL_PORT=<SMTP Port>
$ go build -ldflags="-w -s" -o iot_api cmd/main.go
$ go run cmd/main.go
Spawn API at :8080 and DB at :5432
$ docker compose up
The REST API Methods to the above app is described below.
GET /v0/nodelog/:date
curl -i -H 'Content-Type: application/json' http://localhost:8080/v0/nodelog/2000-06-28
POST /v0/nodelog/
curl -i -H 'Content-Type: application/json' -d '{"relname": " " , "ipaddr": " ", "datetime": " "}' http://localhost:8080/v0/nodelog/
GET /v0/userrel/:rel
curl -i -H 'Content-Type: application/json' http://localhost:8080/v0/nodelog/name
POST /v0/userrel/
curl -i -H 'Content-Type: application/json' -d '{"name": " ", "rel": " ", "email": " "}' http://localhost:8080/v0/userrel
PUT /v0/userrel/:name
curl -i -H 'Content-Type: application/json' -d '{"name": " ", "rel": " ", "email": " "}' http://localhost:8080/v0/name
DELETE /v0/userrel/:name
curl -i -H 'Content-Type: application/json' http://localhost:8080/v0/name
GET /v0/getlog
curl http://localhost:8080/v0/getlog