ginweb

package module
v0.0.0-...-2eec03b Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: Apache-2.0 Imports: 7 Imported by: 2

README

GinWeb

A golang web project template based on gin framework

Features:

gin本身已经相当灵活,但是由于项目中有一些模块是我们必须或者经常使用的,所以进行了集成,如果不需要这些模块或者要使用自己的模块实现,请考虑直接使用gin框架

  1. 集成endless在类Unix平台下实现不停机重启服务
  2. 集成log4go: 类似于log4j的配置式的log输出,可以控制日记级别,输出格式以及滚动
  3. 集成recovery: 出错时尝试进行恢复并使用log4go记录为critical级别

USAGE:

func main() {
    r := ginweb.NewGinweb()
    
    r.GET("/welcome", func(c *gin.Context) {
        firstname := c.DefaultQuery("firstname", "Guest")
        lastname := c.Query("lastname")
        c.String(http.StatusOK, "Hello %s %s", firstname, lastname)
    })
    
    r.Run(conf.Conf.SERVER.PORT)
}

后台启动app(供参考):

$> nohup ./appname > /dev/null 2>stderr.log &

不停机重启服务(在在Unix/Linux/Mac)上能起作用:

$> pgrep appname | xargs kill -HUP

TODO:

  1. Portable模式, 支持内嵌conf.yml文件和log4go.xml文件, 构建时将生成一个唯一的一个可执行文件, 单个文件更便于分发。

Documentation

Overview

 Description: ginweb is light weight wrap of gin framework  Author: ZHU HAIHUA  Since: 2016-02-28 14:57

Author: ZHU HAIHUA Date: 9/8/16

Index

Constants

View Source
const VERSION = "0.0.1"

Variables

This section is empty.

Functions

func New

func New() *gin.Engine

func RegisterComponent

func RegisterComponent(name string, config interface{}, initialize func(config interface{}) error)

func RegisterComponentScheduler

func RegisterComponentScheduler(name string, initialize func(config interface{}) error, config interface{}, delay, interval time.Duration)

TODO: DO NOT USE!!

func Run

func Run(port string, engin *gin.Engine, args ...interface{})

args[0]: type time.Duration as the DefaultHammerTime of endless, will be ignore on Windows

Types

type Ginweb

type Ginweb struct {
	*gin.Engine
}

func NewGinweb

func NewGinweb() *Ginweb

func (*Ginweb) Run

func (ginweb *Ginweb) Run(port string, args ...interface{})

args[0]: type time.Duration as the DefaultHammerTime of endless, will be ignore on Windows

Directories

Path Synopsis
Description: conf 项目配置项,也用于读取当前目录下的app.conf中的项目 Author: ZHU HAIHUA Since: 2016-02-26 19:19
Description: conf 项目配置项,也用于读取当前目录下的app.conf中的项目 Author: ZHU HAIHUA Since: 2016-02-26 19:19
const
errcode
Description: errcode 错误码定义 Author: ZHU HAIHUA Since: 2016-02-26 20:37
Description: errcode 错误码定义 Author: ZHU HAIHUA Since: 2016-02-26 20:37
 Description: conf log 实现日志相关的配置项  Author: ZHU HAIHUA  Since: 2016-02-27 15:10  Description: conf recovery 用于顶层的错误恢复,并将错误堆栈记录到日志中.
 Description: conf log 实现日志相关的配置项  Author: ZHU HAIHUA  Since: 2016-02-27 15:10  Description: conf recovery 用于顶层的错误恢复,并将错误堆栈记录到日志中.
Description: server 提供抽象的服务器接口。
Description: server 提供抽象的服务器接口。
Description: util Author: ZHU HAIHUA Since: 2016-03-15 13:13 Description: util Author: ZHU HAIHUA Since: 2016-02-29 21:41
Description: util Author: ZHU HAIHUA Since: 2016-03-15 13:13 Description: util Author: ZHU HAIHUA Since: 2016-02-29 21:41
http
Description: http Author: ZHU HAIHUA Since: 2016-03-02 20:46
Description: http Author: ZHU HAIHUA Since: 2016-03-02 20:46
param
 Description: model  Author: ZHU HAIHUA  Since: 2016-02-28 20:59
 Description: model  Author: ZHU HAIHUA  Since: 2016-02-28 20:59
query
 Description: query  Author: ZHU HAIHUA  Since: 2016-02-28 21:46
 Description: query  Author: ZHU HAIHUA  Since: 2016-02-28 21:46
response
Description: utils 服务器应答标准结构 Author: ZHU HAIHUA Since: 2016-02-26 20:31
Description: utils 服务器应答标准结构 Author: ZHU HAIHUA Since: 2016-02-26 20:31

Jump to

Keyboard shortcuts

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