Documentation ¶
Index ¶
- Constants
- Variables
- func AddCmdRouter(use, short string, action CmdHandlerFunc, args ...ICmdArg)
- func AddTaskRouter(spec string, action TaskHandlerFunc)
- func GetAppName() string
- func GetLang() string
- func GetTranslator(lang ...string) ut.Translator
- func Hostname() string
- func HttpUse(middleware ...HttpHandlerFunc)
- 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 CmdBoolArg
- type CmdDurationArg
- type CmdFloat64Arg
- type CmdHandlerFunc
- type CmdInt64Arg
- type CmdIntArg
- type CmdIntSliceArg
- type CmdRouter
- type CmdStringArg
- type CmdStringSliceArg
- type Ctx
- func (c *Ctx) AbortWithE(err error)
- 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 HTTPCodeError
- type HttpGlobalMiddleware
- type HttpGroupRouter
- func (g *HttpGroupRouter) Any(url string, actions ...HttpHandlerFunc) *HttpRouter
- func (g *HttpGroupRouter) Delete(url string, actions ...HttpHandlerFunc) *HttpRouter
- func (g *HttpGroupRouter) Get(url string, actions ...HttpHandlerFunc) *HttpRouter
- func (g *HttpGroupRouter) Group(prefix string, middleware ...HttpHandlerFunc) *HttpGroupRouter
- func (g *HttpGroupRouter) Head(url string, actions ...HttpHandlerFunc) *HttpRouter
- func (g *HttpGroupRouter) Options(url string, actions ...HttpHandlerFunc) *HttpRouter
- func (g *HttpGroupRouter) Patch(url string, actions ...HttpHandlerFunc) *HttpRouter
- func (g *HttpGroupRouter) Post(url string, actions ...HttpHandlerFunc) *HttpRouter
- func (g *HttpGroupRouter) Put(url string, actions ...HttpHandlerFunc) *HttpRouter
- func (g *HttpGroupRouter) Use(middlewares ...HttpHandlerFunc)
- type HttpHandlerFunc
- type HttpRouter
- type ICmdArg
- type ResponseBody
- type TaskHandlerFunc
- type TaskRouter
Constants ¶
View Source
const ( ResponseKey = "__Resp__" ErrorKey = "__Error__" )
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 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 AddTaskRouter ¶
func AddTaskRouter(spec string, action TaskHandlerFunc)
func GetAppName ¶ added in v1.4.0
func GetAppName() string
func GetTranslator ¶ added in v1.3.0
func GetTranslator(lang ...string) ut.Translator
func HttpUse ¶ added in v1.6.0
func HttpUse(middleware ...HttpHandlerFunc)
func RestartApp ¶ added in v1.1.8
func RestartApp() error
func SetHttpNoRouter ¶ added in v1.2.9
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 AppConfig ¶
var Config *AppConfig
func NewAppConfig ¶
func (*AppConfig) ReadFileConfig ¶ added in v1.4.5
type Cmd ¶
func (*Cmd) LoadCmdRouter ¶
func (c *Cmd) LoadCmdRouter()
type CmdBoolArg ¶ added in v1.2.6
func (CmdBoolArg) SetFlag ¶ added in v1.2.6
func (c CmdBoolArg) SetFlag(cmd *cobra.Command)
type CmdDurationArg ¶ added in v1.2.6
type CmdDurationArg struct { Name string Shorthand string Usage string Required bool Value time.Duration }
func (CmdDurationArg) SetFlag ¶ added in v1.2.6
func (c CmdDurationArg) SetFlag(cmd *cobra.Command)
type CmdFloat64Arg ¶ added in v1.2.6
func (CmdFloat64Arg) SetFlag ¶ added in v1.2.6
func (c CmdFloat64Arg) SetFlag(cmd *cobra.Command)
type CmdInt64Arg ¶ added in v1.2.6
func (CmdInt64Arg) SetFlag ¶ added in v1.2.6
func (c CmdInt64Arg) SetFlag(cmd *cobra.Command)
type CmdIntSliceArg ¶ added in v1.2.6
func (CmdIntSliceArg) SetFlag ¶ added in v1.2.6
func (c CmdIntSliceArg) SetFlag(cmd *cobra.Command)
type CmdRouter ¶
type CmdRouter struct { Use string Short string Action CmdHandlerFunc Args []ICmdArg }
type CmdStringArg ¶ added in v1.2.6
func (CmdStringArg) SetFlag ¶ added in v1.2.6
func (c CmdStringArg) SetFlag(cmd *cobra.Command)
type CmdStringSliceArg ¶ added in v1.2.6
type CmdStringSliceArg struct { Name string Shorthand string Usage string Required bool Value []string }
func (CmdStringSliceArg) SetFlag ¶ added in v1.2.6
func (c CmdStringSliceArg) SetFlag(cmd *cobra.Command)
type Ctx ¶
func (*Ctx) AbortWithE ¶ added in v1.6.4
Abort in the middleware with yago error or error
func (*Ctx) GetFileContent ¶ added in v1.4.0
func (*Ctx) GetResponse ¶ added in v1.1.9
func (c *Ctx) GetResponse() (*ResponseBody, bool)
func (*Ctx) SetDataOrErr ¶
func (c *Ctx) SetDataOrErr(data interface{}, err interface{})
type Err ¶
type Err string
type HTTPCodeError ¶ added in v1.6.4
type HTTPCodeError int
func AsHTTPCodeError ¶ added in v1.6.4
func AsHTTPCodeError(err error) (b bool, e HTTPCodeError)
check if err is http code error
func (HTTPCodeError) Code ¶ added in v1.6.4
func (e HTTPCodeError) Code() int
func (HTTPCodeError) Error ¶ added in v1.6.4
func (e HTTPCodeError) Error() string
type HttpGlobalMiddleware ¶ added in v1.6.0
type HttpGlobalMiddleware []HttpHandlerFunc
func (*HttpGlobalMiddleware) Use ¶ added in v1.6.0
func (r *HttpGlobalMiddleware) Use(middleware ...HttpHandlerFunc)
type HttpGroupRouter ¶ added in v1.6.0
type HttpGroupRouter struct { Prefix string GinGroup *gin.RouterGroup Middlewares []HttpHandlerFunc HttpRouterList []*HttpRouter Parent *HttpGroupRouter Children map[string]*HttpGroupRouter }
http group router
func NewHttpGroupRouter ¶ added in v1.6.0
func NewHttpGroupRouter(prefix string, middleware ...HttpHandlerFunc) *HttpGroupRouter
func (*HttpGroupRouter) Any ¶ added in v1.6.0
func (g *HttpGroupRouter) Any(url string, actions ...HttpHandlerFunc) *HttpRouter
func (*HttpGroupRouter) Delete ¶ added in v1.6.0
func (g *HttpGroupRouter) Delete(url string, actions ...HttpHandlerFunc) *HttpRouter
func (*HttpGroupRouter) Get ¶ added in v1.6.0
func (g *HttpGroupRouter) Get(url string, actions ...HttpHandlerFunc) *HttpRouter
func (*HttpGroupRouter) Group ¶ added in v1.6.0
func (g *HttpGroupRouter) Group(prefix string, middleware ...HttpHandlerFunc) *HttpGroupRouter
func (*HttpGroupRouter) Head ¶ added in v1.6.0
func (g *HttpGroupRouter) Head(url string, actions ...HttpHandlerFunc) *HttpRouter
func (*HttpGroupRouter) Options ¶ added in v1.6.0
func (g *HttpGroupRouter) Options(url string, actions ...HttpHandlerFunc) *HttpRouter
func (*HttpGroupRouter) Patch ¶ added in v1.6.0
func (g *HttpGroupRouter) Patch(url string, actions ...HttpHandlerFunc) *HttpRouter
func (*HttpGroupRouter) Post ¶ added in v1.6.0
func (g *HttpGroupRouter) Post(url string, actions ...HttpHandlerFunc) *HttpRouter
func (*HttpGroupRouter) Put ¶ added in v1.6.0
func (g *HttpGroupRouter) Put(url string, actions ...HttpHandlerFunc) *HttpRouter
func (*HttpGroupRouter) Use ¶ added in v1.6.0
func (g *HttpGroupRouter) Use(middlewares ...HttpHandlerFunc)
type HttpRouter ¶
type HttpRouter struct { Group *HttpGroupRouter Path string Method string Actions []HttpHandlerFunc Metadata interface{} }
func GetHttpRouters ¶ added in v1.6.0
func GetHttpRouters() []*HttpRouter
func (*HttpRouter) Url ¶
func (h *HttpRouter) Url() string
func (*HttpRouter) WithMetadata ¶ added in v1.6.3
func (h *HttpRouter) WithMetadata(md interface{}) *HttpRouter
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.