Documentation ¶
Index ¶
- Constants
- func Error(c Code, fs ...*F) error
- func PackageResponse(res interface{}) (int, interface{})
- func PopulateFailedMisResponse(cc *Context, err error, abort bool)
- func PopulateFailedResponse(cc *Context, err error, abort bool)
- func Wrapper(handler HandlerFunc) func(c *gin.Context)
- func WrapperMis(handler HandlerFunc) func(c *gin.Context)
- func WrapperNative(handler HandlerFunc, abort bool) func(c *gin.Context)
- func WrapperRaw(handler HandlerFunc, abort bool) func(c *gin.Context)
- func WrapperString(handler HandlerFunc) func(c *gin.Context)
- func WrapperWithLock(lockFunc LockFunc, unlockFunc UnlockFunc) func(c *gin.Context)
- type Code
- type Context
- func (c *Context) GetName() string
- func (c *Context) GetNameFromParam() string
- func (c *Context) GetNamespace() string
- func (c *Context) GetRequestID() string
- func (c *Context) GetUser() User
- func (c *Context) GetUserInfo() UserInfo
- func (c *Context) LoadBody(obj interface{}) error
- func (c *Context) LoadBodyMulti(obj interface{}) error
- func (c *Context) SetAction(value interface{})
- func (c *Context) SetInfo(key string, value interface{})
- func (c *Context) SetName(n string)
- func (c *Context) SetNamespace(ns string)
- func (c *Context) SetRequestID(requestID string)
- func (c *Context) SetTraceStartTime()
- func (c *Context) SetUser(user User)
- func (c *Context) SetUserInfo(info UserInfo)
- func (c *Context) TraceCostTime(event string)
- type Domain
- type F
- type HandlerFunc
- type LockFunc
- type Role
- type UnlockFunc
- type User
- type UserInfo
Constants ¶
const ( LogKeyRequestID = "requestID" LogKeyAction = "action" ActionExecStartTime = "startTime" )
const ( // * plugin ErrPluginNotFound Code = "ErrPluginNotFound" ErrPluginInvalid = "ErrPluginInvalid" // * request ErrRequestAccessDenied = "ErrRequestAccessDenied" ErrRequestMethodNotFound = "ErrRequestMethodNotFound" ErrRequestParamInvalid = "ErrRequestParamInvalid" // * resource ErrResourceNotFound = "ErrResourceNotFound" ErrResourceAccessForbidden = "ErrResourceAccessForbidden" ErrResourceConflict = "ErrResourceConflict" ErrResourceDeleteForbidden = "ErrResourceDeleteForbidden" ErrResourceHasBeenUsed = "ErrResourceHasBeenUsed" ErrSubResourceExist = "ErrSubResourceExist" ErrNodeNotReady = "ErrNodeNotReady" ErrInvalidToken = "ErrInvalidToken" // * volumes ErrVolumeType = "ErrVolumeType" // * unknown ErrUnknown = "UnknownError" // * application ErrAppNameConflict = "ErrAppNameConflict" ErrVolumeNotFoundWhenMount = "ErrVolumeNotFoundWhenMount" ErrAppReferencedByNode = "ErrAppReferencedByNode" // * node ErrNodeNumMaxLimit = "ErrNodeNumMaxLimit" ErrNodeNumQueryException = "ErrNodeNumQueryException" // * config ErrConfigInUsed = "ErrConfigInUsed" // * register ErrRegisterQuotaNumOut = "ErrRegisterQuotaNumOut" ErrRegisterDeleteRecord = "ErrRegisterDeleteRecord" ErrRegisterDeleteCallback = "ErrRegisterDeleteCallback" ErrRegisterPackage = "ErrRegisterPackage" ErrRegisterRecordActivated = "ErrRegisterRecordActivated" // * db ErrDatabase = "ErrDatabase" ErrUpdateCas = "ErrUpdateCas" // * k8s ErrK8S = "ErrK8S" // * ceph ErrCeph = "ErrCeph" // * io ErrIO = "ErrIO" // * template ErrTemplate = "ErrTemplate" // * function ErrFunction = "ErrFunction" // * resourceName ErrInvalidResourceName = "resourceName" ErrInvalidLabels = "validLabels" ErrInvalidRequired = "required" // * batchOp ErrInvalidArrayLength = "maxLength" // * fingerprintValue ErrInvalidFingerprintValue = "fingerprintValue" // * memory ErrInvalidMemory = "memory" // * duration ErrInvalidDuration = "duration" // * setcpus ErrInvalidSetcpus = "setcpus" // * nonBaetyl ErrInvalidName = "nonBaetyl" // * license ErrLicenseExpired = "ErrLicenseExpired" ErrLicenseQuota = "ErrLicenseQuota" ErrLicenseQuotaAcquire = "ErrLicenseQuotaAcquire" ErrLicenseQuotaRelease = "ErrLicenseQuotaRelease" // * third server error ErrThirdServer = "ErrThirdServer" // * object error ErrObjectOperationException = "ErrObjectOperationException" ErrResourceInvisible = "ErrResourceInvisible" ErrConvertConflict = "ErrConvertConflict" ErrPubsubTimeout = "ErrPubsubTimeout" ErrUpdateSubLabels = "ErrUpdateSubLabels" ErrDataTooLarge = "ErrDataTooLarge" )
all codes
Variables ¶
This section is empty.
Functions ¶
func PackageResponse ¶
func PackageResponse(res interface{}) (int, interface{})
PackageResponse PackageResponse
func PopulateFailedMisResponse ¶
PopulateFailedMisResponse PopulateFailedMisResponse
func PopulateFailedResponse ¶
PopulateFailedResponse PopulateFailedResponse
func Wrapper ¶
func Wrapper(handler HandlerFunc) func(c *gin.Context)
Wrapper Wrapper TODO: to use gin.HandlerFunc ?
func WrapperMis ¶
func WrapperMis(handler HandlerFunc) func(c *gin.Context)
func WrapperNative ¶
func WrapperNative(handler HandlerFunc, abort bool) func(c *gin.Context)
func WrapperRaw ¶
func WrapperRaw(handler HandlerFunc, abort bool) func(c *gin.Context)
func WrapperString ¶
func WrapperString(handler HandlerFunc) func(c *gin.Context)
func WrapperWithLock ¶
func WrapperWithLock(lockFunc LockFunc, unlockFunc UnlockFunc) func(c *gin.Context)
WrapperWithLock wrap handler with lock
Types ¶
type Context ¶
Context context
func NewContextWithLog ¶
NewContext create a new context with log
func NewHttpContext ¶
NewContext create a new context with gin context
func NewTraceContext ¶
NewTraceContext trace contest with start time and field
func (*Context) GetNameFromParam ¶
GetNameFromParam gets name from param if exists
func (*Context) GetNamespace ¶
GetNamespace gets namespace from context if exists
func (*Context) GetRequestID ¶
GetRequestID get log requestID
func (*Context) GetUserInfo ¶
GetUser gets user info from context if exists
func (*Context) LoadBodyMulti ¶
func (*Context) SetAction ¶
func (c *Context) SetAction(value interface{})
SetAction set exec action func
func (*Context) SetNamespace ¶
SetNamespace sets namespace into context
func (*Context) SetRequestID ¶
SetRequestID set log requestID
func (*Context) SetTraceStartTime ¶
func (c *Context) SetTraceStartTime()
SetTraceStartTime set action exec start time
func (*Context) SetUserInfo ¶
SetUser sets user info into context
func (*Context) TraceCostTime ¶
TraceCostTime add from start trace to this func cost time