Documentation
¶
Index ¶
- Variables
- func AddGenOne(handFunName, routerPath string, methods []string)
- func GetEmptyConfig() []byte
- func NewAPIFunc(c *gin.Context) interface{}
- func RegisterFuncGetResult(i FuncGetResult)
- type ApiFunc
- type Context
- func (c *Context) DataExit(data interface{})
- func (c *Context) Exit()
- func (c *Context) FailAndExit(data ...interface{})
- func (c *Context) GetPageSize() (int, int)
- func (c *Context) GetQueryBool(key string) bool
- func (c *Context) GetQueryInt(key string, def ...int) int
- func (c *Context) GetQueryInt64(key string) int64
- func (c *Context) GetQueryString(key string) string
- func (c *Context) GetQueryUInt(key string) uint
- func (c *Context) GetQueryUInt64(key string) uint64
- func (c *Context) GetVersion() string
- func (c *Context) ListExit(count int64, list interface{})
- func (c *Context) Method() string
- func (c *Context) NoPermissionExit(msg ...string)
- func (c *Context) NotFoundExit(msg ...string)
- func (c *Context) SaveFile(form string, dst string) error
- func (c *Context) SuccessExit(data ...interface{})
- func (c *Context) WriteJSON(obj interface{})
- type DefaultBeforeAfter
- type FuncGetResult
- type Interceptor
- type InterceptorContext
- type KApi
- type Option
- type RESULT_CODE
- type RecoverErrorFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ( VERSION string BUILDTIME string GOVERSION string OS string ARCH string PACKAGENAME string )
编译时植入变量
View Source
var GetResultFunc = _defaultGetResult
View Source
var KAPIEXIT = "kapiexit"
Functions ¶
func GetEmptyConfig ¶ added in v0.3.1
func GetEmptyConfig() []byte
func NewAPIFunc ¶ added in v0.3.0
NewAPIFunc default of custom handlefunc
func RegisterFuncGetResult ¶ added in v0.3.0
func RegisterFuncGetResult(i FuncGetResult)
RegisterFuncGetResult 注册返回json结构的func
Types ¶
type Context ¶
Context Wrapping gin context to custom context
func (*Context) FailAndExit ¶
func (c *Context) FailAndExit(data ...interface{})
func (*Context) GetPageSize ¶
func (*Context) GetQueryBool ¶
func (*Context) GetQueryInt64 ¶
func (*Context) GetQueryString ¶
func (*Context) GetQueryUInt ¶
func (*Context) GetQueryUInt64 ¶
func (*Context) GetVersion ¶ added in v0.3.0
GetVersion Get the version by req url
func (*Context) NoPermissionExit ¶
func (*Context) NotFoundExit ¶
func (*Context) SuccessExit ¶
func (c *Context) SuccessExit(data ...interface{})
type DefaultBeforeAfter ¶ added in v0.3.0
type DefaultBeforeAfter struct {
}
DefaultBeforeAfter 默认 BeforeAfter Middleware
func (*DefaultBeforeAfter) After ¶ added in v0.3.0
func (d *DefaultBeforeAfter) After(req *InterceptorContext) bool
After call之后调用
func (*DefaultBeforeAfter) Before ¶ added in v0.3.0
func (d *DefaultBeforeAfter) Before(req *InterceptorContext) bool
Before call之前调用
type FuncGetResult ¶ added in v0.3.0
type FuncGetResult = func(code RESULT_CODE, msg string, count int64, data interface{}) (int, interface{})
type Interceptor ¶
type Interceptor interface {
Before(req *InterceptorContext) bool
After(req *InterceptorContext) bool
}
Interceptor 对象调用前后执行中间件(支持总的跟对象单独添加)
type InterceptorContext ¶ added in v0.3.0
type InterceptorContext struct {
C *Context
FuncName string // 函数名
Req interface{} // 调用前的请求参数
Resp interface{} // 调用后的响应参数
RespCode int //状态码
Error error // 错误信息
Context context.Context // 占位上下文参数,可用于存储其他参数,前后连接可用
}
InterceptorContext 对象调用前后执行中间件参数
type KApi ¶
type KApi struct {
// contains filtered or unexported fields
}
KApi base struct
func (*KApi) RegisterRouter ¶
func (b *KApi) RegisterRouter(cList ...interface{})
type Option ¶
type Option struct {
Server struct {
Debug bool `conf:"debug" default:"true"`
NeedDoc bool `conf:"needDoc" default:"true"`
NeedReDoc bool `conf:"needReDoc" default:"false"`
NeedSwagger bool `conf:"needSwagger" default:"true"`
DocName string `conf:"docName" default:"K-Api"`
DocDesc string `conf:"docDesc" default:"K-Api"`
Port int `conf:"port" default:"2022"`
OpenDocInBrowser bool `conf:"openDocInBrowser" default:"true"`
DocDomain string `conf:"docDomain"`
DocVer string `conf:"docVer" default:"v1"`
RedirectToDocWhenAccessRoot bool `conf:"redirectToDocWhenAccessRoot" default:"true"`
APIBasePath string `conf:"apiBasePath" default:""`
StaticDirs []string `conf:"staticDirs" default:"[static]"`
EnablePProf bool `conf:"enablePProf" default:"false"`
Cors struct {
AllowHeaders []string `conf:"allowHeaders" default:"[Origin,Content-Length,Content-Type,Authorization,x-requested-with]"`
} `conf:"cors"`
} `conf:"server"`
// contains filtered or unexported fields
}
func (*Option) SetGinLoggerFormatter ¶
func (o *Option) SetGinLoggerFormatter(formatter gin.LogFormatter) *Option
func (*Option) SetIntranetIP ¶
func (*Option) SetRecoverFunc ¶
type RESULT_CODE ¶ added in v0.3.0
type RESULT_CODE int
const ( RESULT_CODE_SUCCESS RESULT_CODE = iota //SuccessExit DataExit ListExit 时 RESULT_CODE_FAIL // FailExit RESULT_CODE_ERROR //FailExit时传参error RESULT_CODE_UNAUTHED RESULT_CODE_NOPERMISSION RESULT_CODE_NOTFOUND )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.