Documentation ¶
Index ¶
- Constants
- Variables
- func AddCmdRouter(use, short string, action CmdHandlerFunc, args ...ICmdArg)
- func AddHttpRouter(url, method string, action HttpHandlerFunc, h HttpInterface, md ...interface{})
- func AddTaskRouter(spec string, action TaskHandlerFunc)
- func GetAppName() string
- 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 WrapErr(ye Err, err error) 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) Copy() *Ctx
- func (c *Ctx) GetError() error
- func (c *Ctx) GetFileContent(key string) ([]byte, error)
- func (c *Ctx) GetResponse() (*ResponseBody, bool)
- func (c *Ctx) SetData(data interface{})
- func (c *Ctx) SetDataOrErr(data interface{}, err interface{})
- func (c *Ctx) SetError(err interface{})
- type Err
- type HttpHandlerFunc
- type HttpInterface
- type HttpRouter
- type ICmdArg
- type ResponseBody
- type TaskHandlerFunc
- type TaskRouter
Constants ¶
View Source
const CtxParamsKey = "__PARAMS__"
Variables ¶
View Source
var ( 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 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, md ...interface{})
func AddTaskRouter ¶
func AddTaskRouter(spec string, action TaskHandlerFunc)
func GetAppName ¶ added in v1.4.10
func GetAppName() string
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 // http biz log HttpBizLogOn bool // 开启task服务 TaskEnable bool // task路由配置 TaskRouters []*TaskRouter // rpc RpcEnable bool // contains filtered or unexported fields }
type AppConfig ¶
var Config *AppConfig
func NewAppConfig ¶
func (*AppConfig) ReadFileConfig ¶ added in v1.6.0
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) GetFileContent ¶ added in v1.4.10
func (*Ctx) GetResponse ¶
func (c *Ctx) GetResponse() (*ResponseBody, bool)
func (*Ctx) SetDataOrErr ¶
func (c *Ctx) SetDataOrErr(data interface{}, err interface{})
type Err ¶
type Err string
type HttpInterface ¶
type HttpRouter ¶
type HttpRouter struct { Url string Method string Action HttpHandlerFunc Metadata interface{} // 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. |
libs
|
|
Click to show internal directories.
Click to hide internal directories.