An example of a restful style api service program written in go language based on Gin.
- Based on gin
- Use MongoDB database
- gin-jwt permission verification
- gin-sessions
- gin-authz Get the user's role from the session for permission management
- Use gin-swagger to automatically generate api documentation
- Upgrade gin's default validator.v8 to validator.v9
- Use casbin permission management
- Use go-ini to read and write configuration files
.
├── server.go // entry file
├── docs // api documentation generated by swagger
├── web // Front-end single-page page written by vue
├── common
│ ├── db // mongoDB related
│ ├── utils // Utility function
│ ├── pkg // public package
| | └── e
| | ├── code.go // http status code constant
│ | └── message.go // message constant corresponding to status code
│ ├── validator
| | ├── custom_validate.go // custom validator
│ | └── v8_to_v9.go // Upgrade gin's default validator from v8 to v9
│ └── middlewares
| ├── authz.go // role authentication
│ └── session.go // use session
├── conf // Application configuration related files
| ├── authz
| | ├── model.conf // Rights management scheme configuration
│ | └── policy.csv // permission assignment table
| ├── app.ini // application configuration file
│ └── conf.go // Initialize the configuration file
└── routers
├── routers.go // route initialization
└── api // api file
└── v1 // api version v1
├── v1.go // v1 version api entry
├── mining-machine // mining machine module
| ├── models.go // model and database operations
| ├── controllers.go // controllers for the current module
| ├── routers.go // routes for the current module
| ├── middlewares.go // middleware for the current module
| └── validators.go // validators for the current module
└── user // user module
├── models.go // model and database operations
├── controllers.go // controllers for the current module
├── routers.go // routes for the current module
├── middlewares.go // middleware for the current module
└── validators.go // validators for the current module