This project demos serving golang/gin based REST CRUD APIs.
The code follows the tutorial at: https://www.allhandsontech.com/programming/golang/web-app-sqlite-go/
This project serves as a backend for https://github.com/ns-code/ng18-maintainusers-refactored
It uses an embedded SQLLite DB. The following APIs are currently supported:
GET /api/users POST /api/users PUT /api/users/{userId} DELETE /api/users/{userId}
The Release-1.0.0 uses gin and std database/sql packages. The Release-2.1.0 uses gorilla/mux and sqlx packages
After cloning this repo, download and install https://jmeubank.github.io/tdm-gcc/download/ and set the PATH
Then run
go env -w CGO_ENABLED=1
The apis can be unit tested by running:
go test -v ./apis_test.go
Start the web application using:
go run .
With the app running in one command pad, run the following in another command pad:
go test -v ./integrationtests/apis_integration_test.go
All the APIs mentioned above can also be integration tested manually using the Swagger UI:
http://localhost:8080/docs/index.html