quick-rest-go

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

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

Go to latest
Published: Mar 20, 2022 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Introduction

Boilerplate for an HTTP API service, in Golang.

Features

  • ORM with sqlite3 backend.
  • CRUD APIs.
  • Swagger, auto-generated from declarative comments.
  • Documentation by godoc.
  • Unit tests.
  • Logs to stdout (12-factor), collected to Sumo via K8s annotations.
  • Prometheus metrics exported to /metrics, collected to Dash via K8s annotations.
  • Dockerfile.
  • Kubernetes deployment.

Getting started

Simply clone the repo and update functionalities in model package.

Run Service

GIN_MODE=release go run main.go

Regenerate swagger

swag init

Generate documentation

godoc -http=:6060

Go to http://localhost:6060/pkg/github.com/huyanhvn/quick-rest-go/

Unit tests

Boilerplate unit tests are stubbed for model and controller.

huy.nguyen-> GIN_MODE=release go test -v ./...
?       github.com/huyanhvn/quick-rest-go [no test files]
=== RUN   TestController_GetAllItems
--- PASS: TestController_GetAllItems (0.00s)
=== RUN   TestController_GetItemByID
2022/01/19 13:27:01 Setup for unit tests.
=== RUN   TestController_GetItemByID/non-existent_item

2022/01/19 13:27:01 /Users/huy.nguyen/repos/quick-rest-go/model/items.go:73 record not found
[1.054ms] [rows:0] SELECT * FROM `items` WHERE `items`.`id` = 1 ORDER BY `items`.`id` LIMIT 1
2022/01/19 13:27:01 Tear down setup.
--- PASS: TestController_GetItemByID (0.01s)
    --- PASS: TestController_GetItemByID/non-existent_item (0.00s)
=== RUN   TestController_CreateItem
--- PASS: TestController_CreateItem (0.00s)
=== RUN   TestController_UpdateItem
--- PASS: TestController_UpdateItem (0.00s)
=== RUN   TestController_DeleteItem
--- PASS: TestController_DeleteItem (0.00s)
PASS
ok      github.com/huyanhvn/quick-rest-go/controller      (cached)
?       github.com/huyanhvn/quick-rest-go/docs    [no test files]
=== RUN   TestGetAllItems
--- PASS: TestGetAllItems (0.00s)
PASS
ok      github.com/huyanhvn/quick-rest-go/model   (cached)
?       github.com/huyanhvn/quick-rest-go/utils   [no test files]

Deployment

Docker image

docker build -t quick-rest:1.0.0 .

Kubernetes

kubectl apply -f kubernetes.yaml

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT This file was generated by swaggo/swag

Jump to

Keyboard shortcuts

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