ishawge / morningo

gin webapp project skeleton

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MorningGo : Gin WebApp Project Skeleton

Go Report Card

中文文档

A Web develop project skeleton base on Gin which just for reference.

More efficiency,
Faster and clear,
Easier to deploy

Suitable for simple project. kitgo-microkite are better choice for the middle and large project.

Environment Requirements

Installation And Run

Via moroingo installer or use docker

Install

cd $GOPATH/src

wget https://gitee.com/cg33/morningo-installer/raw/master/morningo-installer       # mac
wget https://gitee.com/cg33/morningo-installer/raw/master/morningo-installer-linus # linus
wget https://gitee.com/cg33/morningo-installer/raw/master/morningo-installer.exe   # windows

chmod +x morningo-installer
./morningo-installer --project-name web

Load Dependency

cd web
make deps

Test

make test

Graceful Restart

make restart

Run It

make

visit by browser: http://localhost:4000/api/index

Deploy

First build the executable file

make build # for linus
make cross # for mac/windows

Then put files of the build in your server and set the path of log and static file(html/css/js),and run the executable file.If 80 port is not allowed to use,consider the nginx proxy,or use the gin middleware gin-reverseproxy instead, which has some example in routers.go. When the project start running, it will generate the pidfile in the root path of the project. Excute the following command to update your project.

kill -INT $(cat pid) && ./morningo # graceful stop the process and restart

Project Structure


.
├── Makefile
├── README.md
├── command                     
│   └── sword.go
├── config                      global config
│   └── env.go
├── connections                 store connection
│   ├── database
│   │   ├── mongodb
│   │   └── mysql
│   └── redis
│       └── redis.go
├── controllers                 controller
│   └── MainController.go
├── filters                     middleware
│   ├── auth                    auth middleware
│   │   ├── drivers             auth engine
│   │   └── auth.go   
│   └── filter.go               middleware initer                  
├── frontend                    frontend resource
│   ├── assets
│   │   ├── css
│   │   ├── images
│   │   └── js
│   ├── dist
│   └── templates
│       └── index.tpl
├── handle.go                   global error handler
├── main.go                     
├── models                      model
│   └── User.go
├── module                      module of project
│   │── schedule
│   │   └── schedule.go   
│   │── logger
│   │   └── logger.go 
│   └── server
│       └── server.go 
├── routers                     routers
│   └── api_routers.go       
├── routers.go                  router initer
├── routers_test.go             unit test for api
├── storage                     
│   ├── cache                   cache file
│   └── logs                    log file
│       ├── access.log          
│       └── error.log
└── vendor                      govendor vendor


What`s in the box

HTTP (based on Gin)

  • Router
  • Middleware
  • Controller
  • Request
  • Response
  • View
  • Session

Frontend

  • Go template

Security

  • Authentication
  • Authorization
  • Encryption
  • Hash

Digging Deeper

  • Dancer Command
  • Cache System
  • Error and Log
  • Schedule

Database

  • Mysql
  • Mongodb
  • Redis

ORM(based on gorm)

test

  • Api test

Project Dependency

  • web framework:github.com/gin-gonic/gin
  • orm:github.com/jinzhu/gorm
  • redis:github.com/go-redis/redis
  • mysql:github.com/go-sql-driver/mysql
  • wechat:github.com/silenceper/wechat
  • schedule:github.com/robfig/cron

TODO

  • Logger
  • Test
  • Queue of task
  • Cache/Session
  • Read & Write Connections
  • Redis cluster
  • Profiling(Laravel/Swoole;beego)
  • Command tool
  • Interaction command env

ChangeLog

  • Add Reverse Proxy
  • Fixed the path
  • Add session/cache and Auth middleware
  • Add test
  • Add graceful restart
  • Add schedule module
  • Add installer of project
  • Add access.log and error.log
  • Add database transcation

About

gin webapp project skeleton

License:MIT License


Languages

Language:Go 96.3%Language:Makefile 2.8%Language:Smarty 0.9%