gin-crud-apis

command module
v0.0.0-...-d860576 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 10 Imported by: 0

README

gin-crud-apis README

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}

Releases Info

The Release-1.0.0 uses gin and std database/sql packages. The Release-2.1.0 uses gorilla/mux and sqlx packages

Install

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

Unit Testing

The apis can be unit tested by running:
go test -v ./apis_test.go

Integration Testing

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL