common

package
v0.0.0-...-d07672d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConstPromMetricUrlPath          = "/metrics"
	ConstHttpHealthCheckUrlPath     = "/ping"
	ConstRootUrlPath                = "/"
	ConstHttpSwaggerUrlPath         = "/docs"
	ConstHttpPprofUrlPath           = "/debug/pprof"
	ConstHttpJwtCreateTokenUrlPath  = "/jwt/create"
	ConstHttpJwtRefreshTokenUrlPath = "/jwt/refresh"
)
View Source
const (
	ConstRequestBodyBufferKey  = "REQUEST_BOD_YzdiT5HaFaMF7ZfO556rZRYqn"
	ConstRequestIdGeneratorKey = "REQUEST_ID_HbU3Z3opcTKBSe2O5yZQnSGD"
	ConstRequestMetadataKey    = "REQUEST_METADATA_J4PMFhL1ruM0PT64vRMCwhBu"
	ConstResponseBodyBufferKey = "RESPONSE_BODY_DT6IKLsNULVD3bTgnz1QJbeN"
	ConstRequestLoggerKey      = "REQUEST_LOGGER_3Z3opcTKBSe2O5yZQnSGD"
)
View Source
const (
	ConstPromServiceEndpoint = "listener"
	ConstHttpMethodOverride  = "X-HTTP-Method-Override"
	ConstHttpHostOverride    = "X-HTTP-Host-Override"
	ConstHttpRequestID       = "X-Request-Id"
)
View Source
const (
	ConstHttpRequestIdleConnTimeout = 20 * 1000
)

Variables

This section is empty.

Functions

func CompareAndSwapRequestLogger

func CompareAndSwapRequestLogger(c *gin.Context, logger *zap.SugaredLogger)

将 Http Request Context 中 Logger 通过 atomic 设置到对应的对象指针中

func GetRequestLogger

func GetRequestLogger(c *gin.Context) *zap.SugaredLogger

此处日志受外部定义的日志对象影响 ginAccessLogger 如果这里是异步的日志,可能存在丢日志的风险,性能很高 如果是同步日志,正常写入日志,但是性能会受影响

func SkipResources

func SkipResources(c *gin.Context) bool

Types

type ContextBodyBuff

type ContextBodyBuff struct {
	// contains filtered or unexported fields
}

func NewContextBodyBuff

func NewContextBodyBuff() *ContextBodyBuff

func (*ContextBodyBuff) GetBuffer

func (b *ContextBodyBuff) GetBuffer() *bytes.Buffer

type RequestMetadata

type RequestMetadata struct {
	Host         string
	ClientIP     string
	Listener     string
	OriginWriter gin.ResponseWriter
}

func GetRequestMetadata

func GetRequestMetadata(c *gin.Context) (metadata *RequestMetadata)

type ResponseBodyWriter

type ResponseBodyWriter struct {
	gin.ResponseWriter
	// contains filtered or unexported fields
}

func NewResponseBodyWriter

func NewResponseBodyWriter(w gin.ResponseWriter, b *bytes.Buffer) *ResponseBodyWriter

func (*ResponseBodyWriter) Reset

func (w *ResponseBodyWriter) Reset()

func (*ResponseBodyWriter) Write

func (w *ResponseBodyWriter) Write(b []byte) (int, error)

func (*ResponseBodyWriter) WriteString

func (w *ResponseBodyWriter) WriteString(s string) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL