Documentation
¶
Index ¶
- Variables
- func RegisterFuncGetResult(i FuncGetResult)
- type AfterBind
- type AfterCall
- type BeforeBind
- type BeforeCall
- type Context
- func (c *Context) Apply(ctl interface{}) error
- 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) ListExit(count int64, list interface{})
- func (c *Context) Map(i ...interface{}) inject.TypeMapper
- func (c *Context) MapTo(i interface{}, j interface{}) inject.TypeMapper
- func (c *Context) Method() string
- func (c *Context) NoPerm(msg ...string)
- func (c *Context) NoPermissionExit(msg ...string)
- func (c *Context) NotFoundExit(msg ...string)
- func (c *Context) OfFormFile(form string) (string, int64)
- func (c *Context) Provide(i interface{}) error
- func (c *Context) RemoteAddr() string
- func (c *Context) SaveFile(form string, dst string) error
- func (c *Context) Success(data ...interface{})
- func (c *Context) SuccessExit(data ...interface{})
- func (c *Context) UnAuthed(msg ...string)
- func (c *Context) WriteJSON(obj interface{})
- type ContextInvoker
- type FuncGetResult
- type HeaderAuth
- type Interceptor
- type KApi
- type MethodComment
- type OnError
- type OnPanic
- type OnUnmarshalError
- type OnValidationError
- type Option
- type RESULT_CODE
- type RecoverErrorFunc
- type RouteInfo
- type Server
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 RegisterFuncGetResult ¶ added in v0.3.0
func RegisterFuncGetResult(i FuncGetResult)
RegisterFuncGetResult 注册返回json结构的func
Types ¶
type BeforeBind ¶
type BeforeBind interface {
BeforeBind(c *Context)
}
type BeforeCall ¶
type BeforeCall interface {
BeforeCall(c *Context)
}
type Context ¶
Context KApi Context
func (*Context) FailAndExit ¶
func (c *Context) FailAndExit(data ...interface{})
func (*Context) GetQueryBool ¶
GetQueryBool get query param of boolean
@param key @param def default value @return bool
func (*Context) GetQueryInt ¶
GetQueryInt get query param of integer
@param key @param def default value @return int
func (*Context) GetQueryInt64 ¶
GetQueryInt64 get query param of long
@param key @param def default value @return int64
func (*Context) GetQueryUInt ¶
GetQueryUInt get query param of uint
@param key @param def default value @return uint
func (*Context) GetQueryUInt64 ¶
GetQueryUInt64 get query param of uint64
@param key @param def default value @return uint64
func (*Context) Map ¶
func (c *Context) Map(i ...interface{}) inject.TypeMapper
Map 注入
@param i @return inject.TypeMapper
func (*Context) MapTo ¶
func (c *Context) MapTo(i interface{}, j interface{}) inject.TypeMapper
MapTo 注入为某个接口
@param i 要注入的值(指针) @param j 接口类型(指针) @return inject.TypeMapper
func (*Context) NoPermissionExit ¶
func (*Context) NotFoundExit ¶
func (*Context) RemoteAddr ¶
RemoteAddr returns more real IP address.
func (*Context) SaveFile ¶
SaveFile save form file to destination
@param form name of form file @param dst destination file name @return error
func (*Context) SuccessExit ¶
func (c *Context) SuccessExit(data ...interface{})
type ContextInvoker ¶
type ContextInvoker func(ctx *Context)
ContextInvoker method like this will be FastInvoke by inject package(not use reflect)
type FuncGetResult ¶ added in v0.3.0
type FuncGetResult = func(code RESULT_CODE, msg string, count int64, data interface{}) (int, interface{})
type HeaderAuth ¶
type HeaderAuth interface {
HeaderAuth(c *Context)
}
type Interceptor ¶
Interceptor implement this to intercept controller method
type KApi ¶
func (*KApi) RegisterRouter ¶
func (b *KApi) RegisterRouter(cList ...interface{})
type MethodComment ¶
type MethodComment struct {
Key string //may be [controller name] + / + [method name]. unique
RouterPath string
IsDeprecated bool // will show deprecated in swagger ui
ResultType string //then response type name. eg. model.User or []model.User
Summary string
Description string
Method string //HTTP METHOD
TokenHeader string
}
MethodComment store the comment from controller's method. fields should be exported for gob encoding and decoding
type OnUnmarshalError ¶
type OnValidationError ¶
type Option ¶
type Option struct {
Server Server `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 )
type RouteInfo ¶
type RouteInfo struct {
// contains filtered or unexported fields
}
type Server ¶ added in v0.5.4
type Server struct {
Debug bool `conf:"debug"`
NeedDoc bool `conf:"needDoc"`
DocName string `conf:"docName" default:"K-Api"`
DocDesc string `conf:"docDesc" default:"K-Api"`
Port int `conf:"port" default:"2022"`
DocVer string `conf:"docVer" default:"v1"`
RedirectToDocWhenAccessRoot bool `conf:"redirectToDocWhenAccessRoot"`
StaticDirs []string `conf:"staticDirs" default:"[static=static]"`
EnablePProf bool `conf:"enablePProf"`
Cors struct {
AllowAllOrigins bool `conf:"allowAllOrigins"`
AllowCredentials bool `conf:"allowCredentials"`
MaxAge time.Duration `conf:"maxAge"`
AllowWebSockets bool `conf:"allowWebSockets"`
AllowWildcard bool `conf:"allowWildcard"`
AllowPrivateNetwork bool `conf:"allowPrivateNetwork"`
AllowMethods []string `conf:"allowMethods" d`
AllowHeaders []string `conf:"allowHeaders"`
} `conf:"cors"`
}
Click to show internal directories.
Click to hide internal directories.