Documentation ¶
Index ¶
- Constants
- func AbortWithCodeErr(c *gin.Context, code int, err error)
- func AcquireBuffer() *bytes.Buffer
- func Bind(c *gin.Context, v interface{}, flag int) (err error)
- func BindHeader(c *gin.Context, v interface{}) error
- func BindParam(c *gin.Context, v interface{}) error
- func CloseGinValidator()
- func CodeMsg(code int) string
- func EncodeJSON(v interface{}) (*bytes.Buffer, error)
- func EncodeValues(v interface{}) (url.Values, error)
- func FinishWithCodeData(c *gin.Context, code int, data interface{})
- func FormBindBody(c *gin.Context, v interface{}) error
- func FormBindQuery(c *gin.Context, v interface{}) error
- func FormBindQueryBody(c *gin.Context, v interface{}) error
- func GetRequestHost(req *http.Request) (host string)
- func GetRequestID(c *gin.Context) string
- func HTTPStatus(code int) int
- func HeaderBool(c *gin.Context, key string) (bool, error)
- func HeaderInt64(c *gin.Context, key string) (int64, error)
- func HeaderString(c *gin.Context, key string) (string, error)
- func HeaderUint64(c *gin.Context, key string) (uint64, error)
- func IsGintoolError(err error) bool
- func JSONBindBody(c *gin.Context, v interface{}) error
- func JSONUseNumber(enabled bool)
- func MsgpackBindBody(c *gin.Context, v interface{}) error
- func MustBind(c *gin.Context, v interface{}, flag int, cbs ...CallbackFunc)
- func MustBindHeader(c *gin.Context, v interface{}, cbs ...CallbackFunc)
- func MustBindParam(c *gin.Context, v interface{}, cbs ...CallbackFunc)
- func MustDo(run RunFunc, codes ...int) interface{}
- func MustDoCallback(run RunFunc, code int, cbs ...CallbackFunc) interface{}
- func MustEncodeJSON(v interface{}, cbs ...CallbackFunc) *bytes.Buffer
- func MustEncodeValues(v interface{}, cbs ...CallbackFunc) url.Values
- func MustFormBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
- func MustFormBindQuery(c *gin.Context, v interface{}, cbs ...CallbackFunc)
- func MustFormBindQueryBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
- func MustHeaderBool(c *gin.Context, key string, cbs ...CallbackFunc) bool
- func MustHeaderInt64(c *gin.Context, key string, cbs ...CallbackFunc) int64
- func MustHeaderString(c *gin.Context, key string, cbs ...CallbackFunc) string
- func MustHeaderUInt64(c *gin.Context, key string, cbs ...CallbackFunc) uint64
- func MustJSONBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
- func MustMsgpackBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
- func MustPBBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
- func MustParamBool(c *gin.Context, key string, cbs ...CallbackFunc) bool
- func MustParamInt64(c *gin.Context, key string, cbs ...CallbackFunc) int64
- func MustParamString(c *gin.Context, key string, cbs ...CallbackFunc) string
- func MustParamUInt64(c *gin.Context, key string, cbs ...CallbackFunc) uint64
- func MustPostFormBool(c *gin.Context, key string, cbs ...CallbackFunc) bool
- func MustPostFormInt64(c *gin.Context, key string, cbs ...CallbackFunc) int64
- func MustPostFormString(c *gin.Context, key string, cbs ...CallbackFunc) string
- func MustPostFormUInt64(c *gin.Context, key string, cbs ...CallbackFunc) uint64
- func MustQueryBool(c *gin.Context, key string, cbs ...CallbackFunc) bool
- func MustQueryInt64(c *gin.Context, key string, cbs ...CallbackFunc) int64
- func MustQueryString(c *gin.Context, key string, cbs ...CallbackFunc) string
- func MustQueryUInt64(c *gin.Context, key string, cbs ...CallbackFunc) uint64
- func MustValidate(v interface{}, cbs ...CallbackFunc)
- func MustXMLBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
- func PBBindBody(c *gin.Context, v interface{}) error
- func ParamBool(c *gin.Context, key string) (bool, error)
- func ParamInt64(c *gin.Context, key string) (int64, error)
- func ParamString(c *gin.Context, key string) (string, error)
- func ParamUint64(c *gin.Context, key string) (uint64, error)
- func PostFormBool(c *gin.Context, key string) (bool, error)
- func PostFormInt64(c *gin.Context, key string) (int64, error)
- func PostFormString(c *gin.Context, key string) (string, error)
- func PostFormUint64(c *gin.Context, key string) (uint64, error)
- func QueryBool(c *gin.Context, key string) (bool, error)
- func QueryInt64(c *gin.Context, key string) (int64, error)
- func QueryString(c *gin.Context, key string) (string, error)
- func QueryUint64(c *gin.Context, key string) (uint64, error)
- func RegisterCode(code int, msg string, status int) bool
- func ReleaseBuffer(buffer *bytes.Buffer)
- func ReleaseGintoolError(e *GintoolError)
- func SetRequestID(f func(*gin.Context) string) gin.HandlerFunc
- func Validate(v interface{}) error
- func XMLBindBody(c *gin.Context, v interface{}) error
- type CallbackFunc
- type CommonResponse
- type Context
- type EmptyError
- type Engine
- type GintoolError
- type HandlerFunc
- type HandlerFuncsChain
- type Kind
- type Option
- type RunFunc
Constants ¶
View Source
const ( CodeOKZero = 0 CodeOK = 2000 CodeCreated = 2001 CodePartialContent = 2006 CodeMultipleChoices = 3000 CodeMovedPermanently = 3001 CodeFound = 3002 CodeSeeOther = 3003 CodeNotModified = 3004 CodeUseProxy = 3005 CodeTemporaryRedirect = 3007 CodePermanentRedirect = 3008 CodeBadRequest = 4000 CodeForbidden = 4003 CodeNotFound = 4004 CodeTooManyRequests = 4029 CodeValidateErr = 4050 CodeInternalErr = 5000 CodeParseDataErr = 5013 CodeDBErr = 5014 CodeHbaseErr = 5015 CodeRedisErr = 5016 CodeDiskErr = 5017 CodeNSQErr = 5030 CodeKafkaErr = 5031 CodeBindErr = 5040 CodeEncodeErr = 5041 CodeDownstreamErr = 5100 )
View Source
const ( BValidator = 1 << iota BHeader BParam BJSONBody BXMLBody BFormQuery BFormBody BFormQueryBody BPBBody BMsgpackBody )
View Source
const (
KeyRequestID = "gintool_request_id"
)
View Source
const (
UnknownStatus = 900
)
Variables ¶
This section is empty.
Functions ¶
func AcquireBuffer ¶
func BindHeader ¶
BindHeader needs tag "header" in fields of v. The value of tag "header" is automatically converted to the canonical format.
func CloseGinValidator ¶
func CloseGinValidator()
func EncodeJSON ¶
EncodeJSON needs tag "json" in fields of v. Note: ReleaseBuffer needs to be called after EncodeJSON is called successfully.
func EncodeValues ¶
EncodeValues needs tag "url" in fields of v.
func FinishWithCodeData ¶
func FormBindBody ¶
FormBindBody needs tag "form" in fields of v.
func FormBindQuery ¶
FormBindQuery needs tag "form" in fields of v.
func FormBindQueryBody ¶
FormBindQueryBody needs tag "form" in fields of v.
func GetRequestHost ¶
func GetRequestID ¶
func HTTPStatus ¶
func IsGintoolError ¶
func JSONBindBody ¶
func JSONUseNumber ¶
func JSONUseNumber(enabled bool)
func MsgpackBindBody ¶
func MustBindHeader ¶
func MustBindHeader(c *gin.Context, v interface{}, cbs ...CallbackFunc)
func MustBindParam ¶
func MustBindParam(c *gin.Context, v interface{}, cbs ...CallbackFunc)
func MustDoCallback ¶
func MustDoCallback(run RunFunc, code int, cbs ...CallbackFunc) interface{}
MustDoCallback will call cbs if and only if run has error.
func MustEncodeJSON ¶
func MustEncodeJSON(v interface{}, cbs ...CallbackFunc) *bytes.Buffer
MustEncodeJSON needs tag "json" in fields of v. Note: ReleaseBuffer needs to be called after MustEncodeJSON is called successfully.
func MustEncodeValues ¶
func MustEncodeValues(v interface{}, cbs ...CallbackFunc) url.Values
func MustFormBindBody ¶
func MustFormBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
func MustFormBindQuery ¶
func MustFormBindQuery(c *gin.Context, v interface{}, cbs ...CallbackFunc)
func MustFormBindQueryBody ¶
func MustFormBindQueryBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
func MustHeaderBool ¶
func MustHeaderBool(c *gin.Context, key string, cbs ...CallbackFunc) bool
func MustHeaderInt64 ¶
func MustHeaderInt64(c *gin.Context, key string, cbs ...CallbackFunc) int64
func MustHeaderString ¶
func MustHeaderString(c *gin.Context, key string, cbs ...CallbackFunc) string
func MustHeaderUInt64 ¶
func MustHeaderUInt64(c *gin.Context, key string, cbs ...CallbackFunc) uint64
func MustJSONBindBody ¶
func MustJSONBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
func MustMsgpackBindBody ¶
func MustMsgpackBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
func MustPBBindBody ¶
func MustPBBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
func MustParamBool ¶
func MustParamBool(c *gin.Context, key string, cbs ...CallbackFunc) bool
func MustParamInt64 ¶
func MustParamInt64(c *gin.Context, key string, cbs ...CallbackFunc) int64
func MustParamString ¶
func MustParamString(c *gin.Context, key string, cbs ...CallbackFunc) string
func MustParamUInt64 ¶
func MustParamUInt64(c *gin.Context, key string, cbs ...CallbackFunc) uint64
func MustPostFormBool ¶
func MustPostFormBool(c *gin.Context, key string, cbs ...CallbackFunc) bool
func MustPostFormInt64 ¶
func MustPostFormInt64(c *gin.Context, key string, cbs ...CallbackFunc) int64
func MustPostFormString ¶
func MustPostFormString(c *gin.Context, key string, cbs ...CallbackFunc) string
func MustPostFormUInt64 ¶
func MustPostFormUInt64(c *gin.Context, key string, cbs ...CallbackFunc) uint64
func MustQueryBool ¶
func MustQueryBool(c *gin.Context, key string, cbs ...CallbackFunc) bool
func MustQueryInt64 ¶
func MustQueryInt64(c *gin.Context, key string, cbs ...CallbackFunc) int64
func MustQueryString ¶
func MustQueryString(c *gin.Context, key string, cbs ...CallbackFunc) string
func MustQueryUInt64 ¶
func MustQueryUInt64(c *gin.Context, key string, cbs ...CallbackFunc) uint64
func MustValidate ¶
func MustValidate(v interface{}, cbs ...CallbackFunc)
func MustXMLBindBody ¶
func MustXMLBindBody(c *gin.Context, v interface{}, cbs ...CallbackFunc)
func PBBindBody ¶
func ReleaseBuffer ¶
func ReleaseGintoolError ¶
func ReleaseGintoolError(e *GintoolError)
func SetRequestID ¶
func SetRequestID(f func(*gin.Context) string) gin.HandlerFunc
func XMLBindBody ¶
Types ¶
type CallbackFunc ¶
type CallbackFunc func(error)
type CommonResponse ¶
type CommonResponse struct { RequestID string `json:"request_id,omitempty"` Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
func RespOK ¶
func RespOK(id string, code int, data interface{}) *CommonResponse
type EmptyError ¶
type EmptyError struct {
// contains filtered or unexported fields
}
func NewEmptyError ¶
func NewEmptyError(kind Kind, key string) *EmptyError
func NewHeaderEmptyError ¶
func NewHeaderEmptyError(key string) *EmptyError
func NewParamEmptyError ¶
func NewParamEmptyError(key string) *EmptyError
func NewPostFormEmptyError ¶
func NewPostFormEmptyError(key string) *EmptyError
func NewQueryEmptyError ¶
func NewQueryEmptyError(key string) *EmptyError
func (EmptyError) Error ¶
func (e EmptyError) Error() string
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) GinHandler ¶
func (e *Engine) GinHandler(handlers ...HandlerFunc) gin.HandlerFunc
func (*Engine) Use ¶
func (e *Engine) Use(middlewares ...HandlerFunc) *Engine
type GintoolError ¶
type GintoolError struct {
// contains filtered or unexported fields
}
func AcquireGintoolError ¶
func AcquireGintoolError(code int, err error) (e *GintoolError)
func (GintoolError) Error ¶
func (e GintoolError) Error() string
func (GintoolError) GetCode ¶
func (e GintoolError) GetCode() int
func (GintoolError) GetError ¶
func (e GintoolError) GetError() error
type HandlerFunc ¶
func GetCommonAborter ¶
func GetCommonAborter() HandlerFunc
func GetCommonFinisher ¶
func GetCommonFinisher() HandlerFunc
type HandlerFuncsChain ¶
type HandlerFuncsChain []HandlerFunc
type Option ¶
type Option func(*Engine)
func WithAborter ¶
func WithAborter(aborter HandlerFunc) Option
func WithFinisher ¶
func WithFinisher(finisher HandlerFunc) Option
Source Files ¶
Click to show internal directories.
Click to hide internal directories.