GIN RMS
The RBAC authority management scaffolding based on GIN + GORM/MONGO + CASBIN + WIRE aims to provide a set of lightweight mid- and back-end development frameworks to facilitate the development of business requirements quickly and easily.
[![ReportCard][reportcard-image]][reportcard-url] [![GoDoc][godoc-image]][godoc-url] [![License][license-image]][license-url]
FEATURES
- Follow the RESTful API design specification & interface-based programming specification
- Based on the
GIN
framework, provides rich middleware support (JWTAuth, CORS, RequestLogger, RequestRateLimiter, TraceID, CasbinEnforce, Recover, GZIP)
- RBAC access control model based on
Casbin
- Permission control can be fine-grained to buttons & interfaces
- Database storage based on
Gorm/Mongo
- The storage layer abstracts the standard external business layer calling interface and uses a closed implementation internally (providing greater convenience for subsequent switching of data storage)
- Dependency injection based on
WIRE
- The role of dependency injection itself is to solve the cumbersome initialization process of hierarchical dependencies between various modules
- Log output is realized based on
Logrus & Context
, and unified TraceID/UserID and other key fields are output by combining with Context (simultaneously support log hooks to write to Gorm/Mongo
)
- User authentication based on
JWT
- Blacklist verification mechanism based on JWT
- Automatically generate
Swagger
documents based on Swaggo
- interface-independent mock implementation
- API unit testing based on
net/http/httptest
standard package
- Dependency management based on
go mod
(domestic sources can be used: https://goproxy.cn/)
- Generate unique ID based on
snowflake
DEPEDENCY
go get -u github.com/cosmtrek/air
go get -u github.com/google/wire/cmd/wire
go get -u github.com/swaggo/swag/cmd/swag
- air -- Live reload for Go apps
- wire -- Compile-time Dependency Injection for Go
- swag -- Automatically generate RESTful API documentation with Swagger 2.0 for Go.
COMPONENT
- Gin -- The fastest full-featured web framework for Go.
- GORM -- The fantastic ORM library for Golang
- Mongo -- The Go driver for MongoDB
- Casbin -- An authorization library that supports access control models like ACL, RBAC, ABAC in Golang
- Wire -- Compile-time Dependency Injection for Go
QUICK START
$ go get -u -v gitlab.tednoc.id/monosense/rms
# Run with AIR tool
$ air
# OR runs based on Makefile
$ make start
# OR Run with go command
$ go run cmd/gin-admin/main.go web -c ./configs/config.toml -m ./configs/model.conf --menu ./configs/menu.yaml
After the startup is successful, you can enter the address in the browser to access:http://127.0.0.1:10088/swagger/index.html
Generate swagger
document
# Based on Makefile
make swagger
# OR use swag command
swag init --generalInfo ./internal/app/swagger.go --output ./internal/app/swagger
Regenerate dependency injection files
# Based on Makefile
make wire
# OR Use the wire command
wire gen ./internal/app/injector
MIT License
Copyright (c) 2020 Lyric