shujanpannag / iot_project_api

This is a REST API built for IoT project using Golang, Gin, and Gorm.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IOT PROJECT API

This is a REST API built for IOT project using Golang, Gin and Gorm.

Requirements

Environment variables (.env)

 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>

Build app binary

    $ go build -ldflags="-w -s" -o iot_api cmd/main.go

Run the app

    $ go run cmd/main.go

Run service

Spawn API at :8080 and DB at :5432

    $ docker compose up

REST API

The REST API Methods to the above app is described below.

Node Log

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/

User Log

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

Server Log

GET /v0/getlog

    curl http://localhost:8080/v0/getlog

About

This is a REST API built for IoT project using Golang, Gin, and Gorm.

License:GNU General Public License v3.0


Languages

Language:Go 94.6%Language:Dockerfile 3.6%Language:Makefile 1.8%