sv

package module
v0.0.0-...-1936dd2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2016 License: MIT Imports: 22 Imported by: 0

README

golang 应用程序框架内核

  • 定义框架目录规范
  • 提供必要的基础服务的封装,例如日志,Graceful restart,全局配置等

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GraceOptions struct {
	AutoRestart bool
	AutoBuild   bool
}

provide the default logger

Functions

func AppBaseDir

func AppBaseDir() string

func AppBinDir

func AppBinDir() string

func AppConfDir

func AppConfDir() string

func AppDataDir

func AppDataDir() string

func AppLogDir

func AppLogDir() string

func AppName

func AppName() string

func AppParseConf

func AppParseConf(i interface{}) error

parse config file by reflection

func AppParseFlags

func AppParseFlags(flagsetName string, i interface{}, flagArgs []string, nonFlagArgs *[]string) error

@param i pointer to struct

func AppRun

func AppRun(app interface{}, args []string) error

func AppWritePidFile

func AppWritePidFile(path string)

func GinRouteStructMethods

func GinRouteStructMethods(r *gin.Engine, controller interface{})

自动路由到 Struct 的所有方法,如果定义 Test:

type Test struct{
	A int
}
func (*Test) Foo(ctx *gin.Context) {
	ctx.JSON(200, gin.H{ "message": "pong", })
}

那么

GinRouteStructMethods(r,&Test{})

相当于

t = &Text{}
r.GET( "/test/foo",func(ctx *gin.Context) { t.Foo(ctx)})
r.GET( "/Test/Foo",func(ctx *gin.Context) { t.Foo(ctx)})
r.POST("/test/foo",func(ctx *gin.Context) { t.Foo(ctx)})
r.POST("/Test/Foo",func(ctx *gin.Context) { t.Foo(ctx)})

func GraceListenAndServe

func GraceListenAndServe(addr string, handler http.Handler, beforebeginFuncs ...func(add string)) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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