Documentation ¶
Index ¶
- Variables
- func AddCmdRouter(use, short string, action CmdHandlerFunc, args ...ICmdArg)
- func AddHttpRouter(url, method string, action HttpHandlerFunc, h HttpInterface)
- func AddTaskRouter(spec string, action TaskHandlerFunc)
- func GetLang() string
- func GetTranslator(lang ...string) ut.Translator
- func Hostname() string
- func IsEnvDev() bool
- func IsEnvProd() bool
- func RestartApp() error
- func SetHttpNoRouter(action HttpHandlerFunc)
- func ValidateHttp(c *Ctx, action string, labels validator.Label, rules []validator.Rule) (bool, error)
- type App
- type AppConfig
- type Cmd
- type CmdArg
- type CmdBoolArg
- type CmdDurationArg
- type CmdFloat64Arg
- type CmdHandlerFunc
- type CmdInt64Arg
- type CmdIntArg
- type CmdIntSliceArg
- type CmdRouter
- type CmdStringArg
- type CmdStringSliceArg
- type Ctx
- func (c *Ctx) GetResponse() (*ResponseBody, bool)
- func (c *Ctx) RequestBool(key string, def ...bool) bool
- func (c *Ctx) RequestFileContent(key string) ([]byte, error)
- func (c *Ctx) RequestFloat64(key string, def ...float64) (float64, error)
- func (c *Ctx) RequestInt(key string, def ...int) (int, error)
- func (c *Ctx) RequestInt64(key string, def ...int64) (int64, error)
- func (c *Ctx) RequestSliceInt(key string, def ...int) ([]int, error)
- func (c *Ctx) RequestSliceInt64(key string, def ...int64) ([]int64, error)
- func (c *Ctx) RequestSliceString(key string, def ...string) []string
- func (c *Ctx) RequestString(key string, def ...string) string
- func (c *Ctx) SetData(data interface{})
- func (c *Ctx) SetDataOrErr(data interface{}, err Err)
- func (c *Ctx) SetError(err interface{}, msgEx ...string)
- func (c *Ctx) Validate() error
- type Err
- type HttpHandlerFunc
- type HttpInterface
- type HttpRouter
- type ICmdArg
- type ResponseBody
- type TaskHandlerFunc
- type TaskRouter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // You can replace yago Err variable in your application,eg. yago.ErrParam = Err("4000=Param err") OK = Err("0") E = Err("1=") // custom error ErrParam = Err("2=") ErrSign = Err("3=Sign failed") ErrAuth = Err("4=Auth failed") ErrForbidden = Err("5=Forbidden") ErrNotLogin = Err("6=User not login") ErrSystem = Err("7=System error") ErrOperate = Err("8=") ErrUnknown = Err("9=Unknown error") )
View Source
var CmdRouterMap = make(map[string]*CmdRouter)
View Source
var Component = new(components)
View Source
var GlobalCloseChan = make(chan int)
View Source
var HttpRouterMap = make(map[string]*HttpRouter)
View Source
var RpcServer *grpc.Server
View Source
var TaskCloseChan = make(chan int)
View Source
var TaskRouterList []*TaskRouter
Functions ¶
func AddCmdRouter ¶
func AddCmdRouter(use, short string, action CmdHandlerFunc, args ...ICmdArg)
func AddHttpRouter ¶
func AddHttpRouter(url, method string, action HttpHandlerFunc, h HttpInterface)
func AddTaskRouter ¶
func AddTaskRouter(spec string, action TaskHandlerFunc)
func GetTranslator ¶ added in v1.3.1
func GetTranslator(lang ...string) ut.Translator
func RestartApp ¶
func RestartApp() error
func SetHttpNoRouter ¶
func SetHttpNoRouter(action HttpHandlerFunc)
Types ¶
type App ¶
type App struct { // 是否开启debug模式 DebugMode bool // http run mode HttpRunMode string // 开启http服务 HttpEnable bool // http路由配置 HttpRouters []*HttpRouter // https 证书配置 HttpSslOn bool HttpCertFile string HttpKeyFile string // http html 模版配置 HttpViewRender bool HttpViewPath string HttpStaticPath string // http cors 跨域配置 HttpCorsAllowAllOrigins bool HttpCorsAllowOrigins []string HttpCorsAllowMethods []string HttpCorsAllowHeaders []string HttpCorsExposeHeaders []string HttpCorsAllowCredentials bool HttpCorsMaxAge time.Duration // http gzip 压缩 HttpGzipOn bool HttpGzipLevel int // http pprof HttpPprof bool // 开启task服务 TaskEnable bool // task路由配置 TaskRouters []*TaskRouter // rpc RpcEnable bool // contains filtered or unexported fields }
type Cmd ¶
func (*Cmd) LoadCmdRouter ¶
func (c *Cmd) LoadCmdRouter()
type CmdArg ¶
type CmdArg = CmdStringArg
type CmdBoolArg ¶
func (CmdBoolArg) SetFlag ¶
func (c CmdBoolArg) SetFlag(cmd *cobra.Command)
type CmdDurationArg ¶
type CmdDurationArg struct { Name string Shorthand string Usage string Required bool Value time.Duration }
func (CmdDurationArg) SetFlag ¶
func (c CmdDurationArg) SetFlag(cmd *cobra.Command)
type CmdFloat64Arg ¶
func (CmdFloat64Arg) SetFlag ¶
func (c CmdFloat64Arg) SetFlag(cmd *cobra.Command)
type CmdInt64Arg ¶
func (CmdInt64Arg) SetFlag ¶
func (c CmdInt64Arg) SetFlag(cmd *cobra.Command)
type CmdIntSliceArg ¶
func (CmdIntSliceArg) SetFlag ¶
func (c CmdIntSliceArg) SetFlag(cmd *cobra.Command)
type CmdRouter ¶
type CmdRouter struct { Use string Short string Action CmdHandlerFunc Args []ICmdArg }
type CmdStringArg ¶
func (CmdStringArg) SetFlag ¶
func (c CmdStringArg) SetFlag(cmd *cobra.Command)
type CmdStringSliceArg ¶
type CmdStringSliceArg struct { Name string Shorthand string Usage string Required bool Value []string }
func (CmdStringSliceArg) SetFlag ¶
func (c CmdStringSliceArg) SetFlag(cmd *cobra.Command)
type Ctx ¶
func (*Ctx) GetResponse ¶
func (c *Ctx) GetResponse() (*ResponseBody, bool)
func (*Ctx) RequestFloat64 ¶
func (*Ctx) RequestSliceInt64 ¶
func (*Ctx) RequestSliceString ¶
func (*Ctx) SetDataOrErr ¶
type Err ¶
type Err string
type HttpInterface ¶
type HttpRouter ¶
type HttpRouter struct { Url string Method string Action HttpHandlerFunc // contains filtered or unexported fields }
type ResponseBody ¶
type TaskRouter ¶
type TaskRouter struct { Spec string Action TaskHandlerFunc }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
base
|
|
coms
|
|
Code generated by yago.
|
Code generated by yago. |
app/modules/home/homerpc/homepb
Package app_homepb is a generated protocol buffer package.
|
Package app_homepb is a generated protocol buffer package. |
app/third/homeapi/homepb
Package app_homepb is a generated protocol buffer package.
|
Package app_homepb is a generated protocol buffer package. |
libs
|
|
Click to show internal directories.
Click to hide internal directories.