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) GetFormFloat32(key string, def ...float32) float32
- func (c *Context) GetFormFloat64(key string, def ...float64) float64
- func (c *Context) GetFormInt(key string, def ...int) int
- func (c *Context) GetFormInt64(key string, def ...int64) int64
- func (c *Context) GetFormString(key string, def ...string) string
- func (c *Context) GetFormUInt(key string, def ...uint) uint
- func (c *Context) GetPageSize(def ...int) (int, int)
- func (c *Context) GetQueryBool(key string) bool
- func (c *Context) GetQueryInt(key string, def ...int) int
- func (c *Context) GetQueryInt64(key string, def ...int64) int64
- func (c *Context) GetQueryString(key string, def ...string) string
- func (c *Context) GetQueryUInt(key string, def ...uint) uint
- func (c *Context) GetQueryUInt64(key string, def ...uint64) 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) MessageAndDataExit(message string, data interface{})
- 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 ¶
var ( VERSION string BUILDTIME string GOVERSION string OS string ARCH string PACKAGENAME string )
编译时植入变量
var GetResultFunc = _defaultGetResult
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) GetFormFloat32 ¶
GetFormFloat32 return the float32 value of query param
@param key @param def @return string
func (*Context) GetFormFloat64 ¶
GetFormFloat64 return the float64 value of form param
@param key @param def @return string
func (*Context) GetFormInt ¶
GetFormInt return the int value of form param
@param key @return string
func (*Context) GetFormInt64 ¶
GetFormInt64 return the int64 value of form param
@param key @return string
func (*Context) GetFormString ¶
GetFormString return the string value of form param
@param key @return string
func (*Context) GetFormUInt ¶
GetFormUInt return the uint value of form param
@param key @return string
func (*Context) GetPageSize ¶
GetPageSize return the values of "page"-1 and "size" query params
@param def def[0] can be the default value of "page" param and def[1] can be the default value of "size" param @return int page-1 @return int size
func (*Context) GetQueryBool ¶
GetQueryBool return the boolean value of query param
@param key @return bool
func (*Context) GetQueryInt ¶
GetQueryInt return the int value of query param
@param key @param def @return int
func (*Context) GetQueryInt64 ¶
GetQueryInt64 return the int64 value of query param
@param key @param def @return int64
func (*Context) GetQueryString ¶
GetQueryString return the string value of query param
@param key @return string
func (*Context) GetQueryUInt ¶
GetQueryUInt return the uint value of query param
@param key @param def @return uint
func (*Context) GetQueryUInt64 ¶
GetQueryUInt64 return the uint64 value of query param
@param key @param def @return uint64
func (*Context) Map ¶
func (c *Context) Map(i ...interface{}) inject.TypeMapper
Map an instance
@param i @return inject.TypeMapper
func (*Context) MapTo ¶
func (c *Context) MapTo(i interface{}, j interface{}) inject.TypeMapper
MapTo map instance to interface
@param i 要注入的值(指针) @param j 接口类型(指针) @return inject.TypeMapper
func (*Context) MessageAndDataExit ¶
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"`
}