http

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllowHeaders = []string{
	"device-id",
	"hardware",
	"tros",
	"os",
	"os_version",
	"location",
	"ip",
	"network_type",
	"timestamp",
	"user_agent",
	"resolution",
	"platform",
	"app_key",
	"app_version",
	"app_vsn",
	"trace_id",
	"token",
	"s-token",
	"run-as",
	"company-id",
	"product",
	"X-Forwarded-For",
	"X-Forwarded-Proto",
	"Authorization",
}
View Source
var AllowOrigins = []string{
	"*",
}
View Source
var ClientReqCounter *prometheus.CounterVec
View Source
var ClientReqDuration *prometheus.HistogramVec
View Source
var ClientReqGauge *prometheus.GaugeVec
View Source
var ServerReqCounter *prometheus.CounterVec
View Source
var ServerReqDuration *prometheus.HistogramVec
View Source
var ServerReqGauge *prometheus.GaugeVec

Functions

func AddTraceID

func AddTraceID(ctx *gin.Context)

func Cors

func Cors() gin.HandlerFunc

解决前端跨域问题

func HTTPLoggerWithConfig

func HTTPLoggerWithConfig(config HTTPConfig) gin.HandlerFunc

HTTPLoggerWithConfig new logger middleware with LoggerConfig

func HeartCheck

func HeartCheck() gin.HandlerFunc

func HttpClientCounter

func HttpClientCounter(url string)

func HttpClientDuration

func HttpClientDuration(url string, e string, cost int64)

func IncCounter

func IncCounter(name string, labelMap map[string]string) error

func Metric

func Metric() gin.HandlerFunc

Metric middleware

func Monitor

func Monitor() gin.HandlerFunc

func Recovery

func Recovery() gin.HandlerFunc

func Start

func Start(appName string, port int)

Start 启动 prometheus 接口服务

func Timeout

func Timeout(timeout time.Duration) func(c *gin.Context)

func UnaryServerInterceptor

func UnaryServerInterceptor() grpc.UnaryServerInterceptor

UnaryServerInterceptor returns unary gRpc tracing middleware

Types

type HTTPConfig

type HTTPConfig struct {
	// Logger logx.Logger instance
	Logger *trlogger.TrLogger
	// Excludes ignore paths
	Excludes []string
}

HTTPConfig http日志打印配置

Jump to

Keyboard shortcuts

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