common

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HTTP 头部键
	HttpHeaderContentType  = "Content-Type"
	HttpHeaderRequestID    = "X-Request-Id"
	HttpHeaderForwardedFor = "X-Forwarded-For"

	// Content-Type 值
	HttpHeaderJSONContentTypeValue       = binding.MIMEJSON
	HttpHeaderXMLContentTypeValue        = binding.MIMEXML
	HttpHeaderPXMLContentTypeValue       = binding.MIMEXML2
	HttpHeaderYAMLContentTypeValue       = binding.MIMEYAML
	HttpHeaderTOMLContentTypeValue       = binding.MIMETOML
	HttpHeaderTextContentTypeValue       = binding.MIMEPlain
	HttpHeaderJavascriptContentTypeValue = "application/javascript"
)

HTTP 头部相关常量

View Source
const (
	EmptyURLPath       = ""
	PromMetricURLPath  = "/metrics"
	HealthCheckURLPath = "/ping"
	RootURLPath        = "/"
	SwaggerURLPath     = "/docs"
	PprofURLPath       = "/debug/pprof"
)

URL 路径相关常量

View Source
const (
	// 请求和响应的缓冲区键
	RequestBodyBufferKey  = "REQUEST_BODY_zdiT5HaFaMF7ZfO556rZRYqn"
	ResponseBodyBufferKey = "RESPONSE_BODY_DT6IKLsNULVD3bTgnz1QJbeN"
	RequestLoggerKey      = "REQUEST_LOGGER_3Z3opcTKBSe2O5yZQnSGD"

	// 请求状态码和消息
	RequestOKCode    int64 = 0
	RequestErrorCode int64 = 10
	RequestOK              = "success"
)

请求相关常量

View Source
const (
	// 服务器关闭的默认超时时间(秒)
	DefaultShutdownTimeoutSeconds = 10

	// HTTP 请求头的默认最大字节数 (2MB)
	DefaultMaxHeaderBytes int = 1 << 21

	// HTTP 连接的默认空闲超时时间(毫秒)
	DefaultHttpIdleTimeoutMillis uint32 = 15000

	// 默认的 HTTP 监听地址和端口
	DefaultHttpListenAddress        = "127.0.0.1"
	DefaultHttpListenPort    uint16 = 8080
)

HTTP 服务器默认配置常量

View Source
const OrbitName = "orbit"

OrbitName 是框架的名称

Variables

View Source
var DefaultConsoleLogger = log.NewZapLogger(nil, false)

默认的控制台日志记录器

View Source
var DefaultLogrLogger = DefaultConsoleLogger.GetLogrLogger().WithName(log.DefaultLoggerName)

默认的 logr 日志记录器

View Source
var DefaultSugeredLogger = DefaultConsoleLogger.GetZapSugaredLogger().Named(log.DefaultLoggerName)

默认的带糖的日志记录器

View Source
var LogEventPool = bp.NewLogEventPool()

用于日志事件的池

View Source
var RequestBodyBufferPool = bp.NewBufferPool(0)

用于请求体的缓冲池

View Source
var ResponseBodyBufferPool = bp.NewBufferPool(0)

用于响应体的缓冲池

Functions

This section is empty.

Types

type CORSPolicy added in v0.1.19

type CORSPolicy struct {
	Enabled          bool     `json:"enabled,omitempty" yaml:"enabled,omitempty"`
	AllowAllOrigins  bool     `json:"allowAllOrigins,omitempty" yaml:"allowAllOrigins,omitempty"`
	AllowedOrigins   []string `json:"allowedOrigins,omitempty" yaml:"allowedOrigins,omitempty"`
	AllowedMethods   []string `json:"allowedMethods,omitempty" yaml:"allowedMethods,omitempty"`
	AllowedHeaders   []string `json:"allowedHeaders,omitempty" yaml:"allowedHeaders,omitempty"`
	ExposeHeaders    []string `json:"exposeHeaders,omitempty" yaml:"exposeHeaders,omitempty"`
	AllowCredentials bool     `json:"allowCredentials,omitempty" yaml:"allowCredentials,omitempty"`
	MaxAgeSeconds    int      `json:"maxAgeSeconds,omitempty" yaml:"maxAgeSeconds,omitempty"`
}

CORSPolicy 定义跨域策略

type LogEventFunc

type LogEventFunc func(logger *logr.Logger, event *log.LogEvent)

LogEventFunc 是用于记录事件的函数类型

Jump to

Keyboard shortcuts

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