Documentation
¶
Index ¶
- Constants
- Variables
- func AddGenOne(handFunName, routerPath string, methods []string)
- 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) 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
- func (o *Option) SetApiBasePath(path string) *Option
- func (o *Option) SetCors(cors cors.Config) *Option
- func (o *Option) SetDocDescription(desc string) *Option
- func (o *Option) SetDocDomain(docDomain string) *Option
- func (o *Option) SetDocName(docName string) *Option
- func (o *Option) SetDocVersion(ver string) *Option
- func (o *Option) SetEnablePProf(enable ...bool) *Option
- func (o *Option) SetGinLoggerFormatter(formatter gin.LogFormatter) *Option
- func (o *Option) SetIntranetIP(ip string) *Option
- func (o *Option) SetIsDebug(isDebug ...bool) *Option
- func (o *Option) SetNeedDoc(needDoc ...bool) *Option
- func (o *Option) SetNeedReDoc(needReDoc ...bool) *Option
- func (o *Option) SetNeedSwagger(needSwagger ...bool) *Option
- func (o *Option) SetOpenDocInBrowser(open ...bool) *Option
- func (o *Option) SetPort(port int) *Option
- func (o *Option) SetRecoverFunc(f func(interface{})) *Option
- func (o *Option) SetRedirectToDocWhenAccessRoot(redirect ...bool) *Option
- func (o *Option) SetStaticDirs(dir ...string) *Option
- type RESULT_CODE
- type RecoverErrorFunc
Constants ¶
View Source
const SECTION_SERVER_NAME = "server"
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 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 {
// contains filtered or unexported fields
}
func (*Option) SetApiBasePath ¶ added in v0.3.0
func (*Option) SetDocDescription ¶ added in v0.3.0
SetDocDescription 设置文档描述
func (*Option) SetDocDomain ¶ added in v0.3.0
func (*Option) SetDocName ¶ added in v0.3.0
SetDocName 设置文档名称
func (*Option) SetDocVersion ¶ added in v0.3.0
SetDocVersion 设置文档版本
func (*Option) SetEnablePProf ¶ added in v0.3.0
func (*Option) SetGinLoggerFormatter ¶
func (o *Option) SetGinLoggerFormatter(formatter gin.LogFormatter) *Option
func (*Option) SetIntranetIP ¶
func (*Option) SetIsDebug ¶ added in v0.3.0
SetIsDebug 设置是否调试模式 当不是开发情况时自动变为false
func (*Option) SetNeedDoc ¶ added in v0.3.0
func (*Option) SetNeedReDoc ¶ added in v0.3.0
func (*Option) SetNeedSwagger ¶ added in v0.3.0
func (*Option) SetOpenDocInBrowser ¶ added in v0.3.0
func (*Option) SetRecoverFunc ¶
func (*Option) SetRedirectToDocWhenAccessRoot ¶ added in v0.3.0
func (*Option) SetStaticDirs ¶ added in v0.3.0
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.