Versions in this module Expand all Collapse all v2 v2.0.1 Apr 22, 2026 v2.0.0 Apr 22, 2026 Changes in this version + const HeaderGlue + const HeaderWildcard + const XAgentIP + const XAgentUID + const XCQRP + const XDBUUID + const XDatakitInfo + const XDatakitUUID + const XDomainName + const XLua + const XPrecision + const XRP + const XSource + const XTableName + const XToken + const XTraceID + const XVersion + const XWorkspaceUUID + var DefaultNamespace = "" + var EnableTracing bool + var ErrTooManyRequest = NewErr(errors.New("reach max API rate limit"), http.StatusTooManyRequests) + var ErrUnexpectedInternalServerError = NewErr(errors.New(`unexpected internal server error`), ...) + var HTTPOK = NewErr(nil, http.StatusOK) + var MaxRequestBodyLen = 128 + func CORSMiddleware(c *gin.Context) + func CORSMiddlewareV2(allowedOrigins []string) gin.HandlerFunc + func DefaultRequestKey(r *http.Request) string + func FormatRequest(r *http.Request) string + func GetStats() map[string]*APIStat + func GinGetArg(c *gin.Context, hdr, param string) (v string, err error) + func GinLogFormatter(param gin.LogFormatterParams) string + func GinRead(c *gin.Context) (buf []byte, err error) + func GinReadWithMD5(c *gin.Context) (buf []byte, md5str string, err error) + func HTTPAPIWrapper(p *WrapPlugins, next apiHandler, args ...interface{}) func(*gin.Context) + func HttpErr(c *gin.Context, err error) + func HttpErrf(c *gin.Context, err error, format string, args ...interface{}) + func Init() + func ReadBody(req *http.Request) ([]byte, error) + func RequestLoggerMiddleware(c *gin.Context) + func StartReporter() + func StopReporter() + func TraceIDMiddleware(c *gin.Context) + func Unzip(in []byte) (out []byte, err error) + type APIMetric struct + API string + Latency time.Duration + Limited bool + StatusCode int + type APIMetricReporter interface + Report func(*APIMetric) + type APIRateLimiter interface + LimitReadchedCallback func(*http.Request) + RequestLimited func(*http.Request) bool + UpdateRate func(float64) + type APIRateLimiterImpl struct + func NewAPIRateLimiter(rate float64, rk RequestKey) *APIRateLimiterImpl + func (rl *APIRateLimiterImpl) LimitReadchedCallback(r *http.Request) + func (rl *APIRateLimiterImpl) RequestLimited(r *http.Request) bool + func (rl *APIRateLimiterImpl) UpdateRate(rate float64) + type APIStat struct + Latency time.Duration + LatencyAvg time.Duration + LatencyMax time.Duration + Limited int + Status1XX int + Status2XX int + Status3XX int + Status4XX int + Status5XX int + Total int + type BodyResp struct + Content interface{} + Message string + type CORSHeaders map[string]struct + func (c CORSHeaders) Add(requestHeaders string) string + func (c CORSHeaders) String() string + type HttpError struct + Err error + ErrCode string + HttpCode int + func NewErr(err error, httpCode int) *HttpError + func NewNamespaceErr(err error, httpCode int, namespace string) *HttpError + func (he *HttpError) Error() string + func (he *HttpError) HttpBody(c *gin.Context, body interface{}) + func (he *HttpError) HttpBodyPretty(c *gin.Context, body interface{}) + func (he *HttpError) WriteBody(c *gin.Context, obj interface{}) + type MsgError struct + Args []interface{} + Fmt string + func Error(he *HttpError, msg string) *MsgError + func Errorf(he *HttpError, format string, args ...interface{}) *MsgError + func (me *MsgError) Error() string + type RateLimiter interface + Limited func(key string) bool + UpdateRate func(float64) + type RawJSONBody []byte + type ReporterImpl struct + func (r *ReporterImpl) Report(m *APIMetric) + type RequestKey func(r *http.Request) string + type SignOption struct + AK string + AuthorizationType string + SK string + Sign string + SignHeaders []string + SignStr string + func DefaultSignOption(authType string, headers []string) *SignOption + func (o *SignOption) ParseAuth(r *http.Request) error + func (o *SignOption) SignReq(r *http.Request) (string, error) + type WrapPlugins struct + Limiter APIRateLimiter + Reporter APIMetricReporter Other modules containing this package github.com/GuanceCloud/cliutils