Documentation ¶
Index ¶
- Constants
- Variables
- func Auth() gin.HandlerFunc
- func AuthAdmin() gin.HandlerFunc
- func CircuitBreaker(opts ...CircuitBreakerOption) gin.HandlerFunc
- func Cors() gin.HandlerFunc
- func CtxRequestID(ctx context.Context) string
- func CtxRequestIDField(ctx context.Context) zap.Field
- func GCtxRequestID(c *gin.Context) string
- func GCtxRequestIDField(c *gin.Context) zap.Field
- func HeaderRequestID(c *gin.Context) string
- func HeaderRequestIDField(c *gin.Context) zap.Field
- func Logging(opts ...Option) gin.HandlerFunc
- func RateLimit(opts ...RateLimitOption) gin.HandlerFunc
- func RequestID() gin.HandlerFunc
- func Tracing(serviceName string, opts ...TraceOption) gin.HandlerFunc
- type CircuitBreakerOption
- type Option
- type RateLimitOption
- type TraceOption
Constants ¶
const ( // ContextRequestIDKey context request id for context ContextRequestIDKey = "request_id" // HeaderXRequestIDKey http header request id key HeaderXRequestIDKey = "X-Request-ID" )
Variables ¶
var ErrLimitExceed = rl.ErrLimitExceed
ErrLimitExceed is returned when the rate limiter is triggered and the request is rejected due to limit exceeded.
var ErrNotAllowed = circuitbreaker.ErrNotAllowed
ErrNotAllowed error not allowed.
Functions ¶
func CircuitBreaker ¶ added in v1.4.0
func CircuitBreaker(opts ...CircuitBreakerOption) gin.HandlerFunc
CircuitBreaker a circuit breaker middleware
func CtxRequestID ¶ added in v1.4.0
CtxRequestID get request id from context.Context
func CtxRequestIDField ¶ added in v1.4.0
CtxRequestIDField get request id field from context.Context
func GCtxRequestID ¶ added in v1.4.0
GCtxRequestID get request id from gin.Context
func GCtxRequestIDField ¶ added in v1.4.0
GCtxRequestIDField get request id field from gin.Context
func HeaderRequestID ¶ added in v1.4.0
HeaderRequestID get request id from the header
func HeaderRequestIDField ¶ added in v1.4.0
HeaderRequestIDField get request id field from header
func RateLimit ¶ added in v1.4.0
func RateLimit(opts ...RateLimitOption) gin.HandlerFunc
RateLimit an adaptive rate limiter middleware
func RequestID ¶ added in v1.3.1
func RequestID() gin.HandlerFunc
RequestID is an interceptor that injects a 'X-Request-ID' into the context and request/response header of each request.
func Tracing ¶ added in v1.3.0
func Tracing(serviceName string, opts ...TraceOption) gin.HandlerFunc
Tracing returns interceptor that will trace incoming requests. The service parameter should describe the name of the (virtual) server handling the request.
Types ¶
type CircuitBreakerOption ¶ added in v1.4.0
type CircuitBreakerOption func(*circuitBreakerOptions)
CircuitBreakerOption set the circuit breaker circuitBreakerOptions.
func WithGroup ¶ added in v1.4.0
func WithGroup(g *group.Group) CircuitBreakerOption
WithGroup with circuit breaker group. NOTE: implements generics circuitbreaker.CircuitBreaker
type Option ¶
type Option func(*options)
Option set the gin logger options.
func WithIgnoreRoutes ¶
WithIgnoreRoutes no logger content routes
func WithRequestIDFromContext ¶ added in v1.3.2
WithRequestIDFromContext name is field in context, default value is request_id
func WithRequestIDFromHeader ¶ added in v1.3.2
WithRequestIDFromHeader name is field in header, default value is X-Request-Id
type RateLimitOption ¶ added in v1.4.0
type RateLimitOption func(*rateLimitOptions)
RateLimitOption set the rate limits rateLimitOptions.
func WithBucket ¶ added in v1.4.0
func WithBucket(b int) RateLimitOption
WithBucket with bucket size.
func WithCPUQuota ¶ added in v1.4.0
func WithCPUQuota(quota float64) RateLimitOption
WithCPUQuota with real cpu quota(if it can not collect from process correct);
func WithCPUThreshold ¶ added in v1.4.0
func WithCPUThreshold(threshold int64) RateLimitOption
WithCPUThreshold with cpu threshold
func WithWindow ¶ added in v1.4.0
func WithWindow(d time.Duration) RateLimitOption
WithWindow with window size.
type TraceOption ¶ added in v1.3.1
type TraceOption func(*traceConfig)
TraceOption specifies instrumentation configuration options.
func WithPropagators ¶ added in v1.3.0
func WithPropagators(propagators propagation.TextMapPropagator) TraceOption
WithPropagators specifies propagators to use for extracting information from the HTTP requests. If none are specified, global ones will be used.
func WithTracerProvider ¶ added in v1.3.0
func WithTracerProvider(provider oteltrace.TracerProvider) TraceOption
WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.