This project has stopped updated, new restful micro service framwork can refer to [xuanwu service] https://github.com/ExcitingFrog/xuanwu
Go-pangu is a Go boilerplate which follows cutting-edge solutions already adopted by the industry, JWT(JSON Web Tokens), Postgres, Redis, Docker, Gin, Ginkgo, Gorm. It is a solid production-ready starting point for your new backend projects.
Golang-pangu is based on following tools
| name | description |
|---|---|
| Go | an open source programming language that makes it easy to build simple, reliable, and efficient software. |
| Gin | web struct based on Go, flexible middleware,strong data binding and outstanding performance. |
| Gorm | The fantastic ORM library for Golang aims to be developer friendly. |
| Ginkgo | Ginkgo builds on Go's testing package, allowing expressive Behavior-Driven Development ("BDD") style tests. |
| JWT | JSON Web Tokens. An open, industry standard RFC 7519 method for representing claims securely between two parties. |
| Postgres | The world's most advanced open source relational database |
| Redis | An open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. |
| Docker | Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. |
.
├── application.yml
├── args
│ ├── args.go
│ └── cmd.go
├── conf
│ ├── conf_debug.go
│ ├── conf.go
│ └── conf_release.go
├── controller
│ ├── application.go
│ ├── auth.go
│ ├── error.go
│ └── session.go
├── db
│ └── db.go
├── Dockerfile
├── go.mod
├── go.sum
├── jwt
│ └── jwt.go
├── main.go
├── Makefile
├── middleware
│ └── middleware.go
├── models
│ ├── base_model.go
│ └── user.go
├── params
│ └── params.go
├── README.md
├── redis
│ └── redis.go
├── routers
│ └── router.go
├── test
│ ├── sign_in_test.go
│ └── test_suite_test.go
└── util
└── util.go
| file | function |
|---|---|
| application.yml | config file |
| args | functions which can fetch params from request url |
| conf | functions which can get configurations |
| controller | handlers |
| db | database operations like migrating database |
| jwt | fuctions to create and check jwt |
| main.go | main function.Call function with "--db" parameter, "create" to create database, "migrate" to migrate tables, "dorp" to delete database |
| middleware | middleware |
| models | base models and basic database operations |
| params | struct used in data binding |
| redis | redis connection and operations |
| router | router |
| test | test |
| i18n | internationalization |
| influx | influx operations include read/save point |
- install postgres, redis
- config application.yml
`make create`(create database) or `go run main.go -db=create`
`make migrate`(migrate tables) or `go run main.go -db=migrate`
`make watch`(with hot reload) or `go run main.go`- open
http://localhost:3002/pingin web browser, and then you will get a "pong" response
-
Post
http://localhost:3002/users/sign_upparams: email, password, password_confirm
Register user
-
Post
http://localhost:3002/users/sign_inparams: email, password, DEVICE_TYPE, login_type
You will get a header with authorization parameter from response after logging in successfully
-
Get
http://localhost:3002/auth_pingShould add a valid user token to request this api
-
Post
http://localhost:3002/users/change_passwordparams: origin_password, password, password_confirm
Modify user's password, which needs authorization
-
Post
http://localhost:3002/citiesparams: language
set language to en, return cities in English. set language to zh, return cities in Chinese.
(Tencent service, need to set your key in application.yml )
-
Get
http://localhost:3002/smsparams: mobile
send sms
(need to install influxdb and modify main.go)
-
Post
http://localhost:3002/influx_saveparams: user_name, local, version
save struct in influxdb
-
Post
http://localhost:3002/influx_saveget struct message in influxdb
(Alipay service, need to set you key in application.yml)
-
Post
http://localhost:3002/alipaycreate alipay bill
-
Post
http://localhost:3002/alipay_notifyreceive pay details notify