Documentation
¶
Index ¶
- func AccessLog(logger *AccessLogger) gin.HandlerFunc
- func CORSMiddleware() gin.HandlerFunc
- func CollectMetrics(c *gin.Context)
- func DynamicDebugLogging(c *gin.Context)
- func NewOpenTelemetryTracing(serviceName string, propagator propagation.TextMapPropagator, ...) gin.HandlerFunc
- func PanicRecovery(logger *log.Logger) gin.HandlerFunc
- type AccessLogger
- type LogItem
- type ResponseWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessLog ¶
func AccessLog(logger *AccessLogger) gin.HandlerFunc
func CORSMiddleware ¶ added in v0.1.9
func CORSMiddleware() gin.HandlerFunc
func CollectMetrics ¶
func DynamicDebugLogging ¶
DynamicDebugLogging open the debug level logging in dynamically
func NewOpenTelemetryTracing ¶
func NewOpenTelemetryTracing(serviceName string, propagator propagation.TextMapPropagator, tracerProvider oteltrace.TracerProvider) gin.HandlerFunc
NewOpenTelemetryTracing returns a Gin middleware function for tracing incoming requests. If no propagator or tracerProvider is provided, it uses the global ones.
func PanicRecovery ¶
func PanicRecovery(logger *log.Logger) gin.HandlerFunc
PanicRecovery uses to catch panic in api handler
Types ¶
type AccessLogger ¶
type AccessLogger struct { IP string // contains filtered or unexported fields }
func NewAccessLogger ¶
func NewAccessLogger(writer io.Writer, pattern string) (*AccessLogger, error)
To set the enabled field as true by default to avoid the need for manual enabling of access log recording.
func (*AccessLogger) Disabled ¶
func (accessLogger *AccessLogger) Disabled()
func (*AccessLogger) Enabled ¶
func (accessLogger *AccessLogger) Enabled()
func (*AccessLogger) SetSlowRequestThreshold ¶
func (accessLogger *AccessLogger) SetSlowRequestThreshold(duration time.Duration)
func (*AccessLogger) Status ¶
func (accessLogger *AccessLogger) Status() string
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Hijacker http.Flusher Status() int // Retrieve the status. Size() int // Retrieve the size. FirstByteTime() time.Time // Retrieve the time of the first byte written. }
ResponseWriter is an interface combining multiple http related interfaces, including http.ResponseWriter, http.Hijacker, and http.Flusher. It also provides additional methods to retrieve status, size and first byte time.
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter) ResponseWriter
Click to show internal directories.
Click to hide internal directories.