middleware

package
v0.0.0-...-2eb6bad Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessLog

func AccessLog(logger *AccessLogger) gin.HandlerFunc

func DynamicDebugLogging

func DynamicDebugLogging(c *gin.Context)

DynamicDebugLogging open the debug level logging in dynamically

func PanicRecovery

func PanicRecovery(logger *log.Logger) gin.HandlerFunc

PanicRecovery uses to catch panic in api handler

func WithTimeout

func WithTimeout(timeout time.Duration, responder gin.HandlerFunc) gin.HandlerFunc

WithTimeout would abort the process of the request if the `timeout` is reached and revoke the responder function.

Types

type AccessLogger

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

func NewAccessLogger

func NewAccessLogger(writer io.Writer, pattern string) (*AccessLogger, error)

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 LogItem

type LogItem struct {
	TraceId        string
	ContentLength  int64
	URL            *url.URL
	RequestHeader  http.Header
	ResponseHeader http.Header
	RemoteAddr     string
	Method         string
	Proto          string
	ReceivedAt     time.Time
	FirstByteTime  time.Time
	Latency        time.Duration
	BytesSent      int
	StatusCode     int
}

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter
	http.Hijacker
	http.Flusher

	Status() int
	Size() int
	FirstByteTime() time.Time
}

func NewResponseWriter

func NewResponseWriter(w http.ResponseWriter) ResponseWriter

Jump to

Keyboard shortcuts

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