middleware

package
v0.0.0-...-fc06233 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const RequestIDKey ctxKeyRequestID = 0

RequestIDKey is the key that holds the unique request ID in a request context.

Variables

This section is empty.

Functions

func Dumper

func Dumper(w io.Writer) func(http.Handler) http.Handler

Dumper returns a debug middleware which prints detailed information about incoming requests and outgoing responses including all headers, parameters and bodies.

func GetReqID

func GetReqID(ctx context.Context) string

GetReqID returns a request ID from the given context if one is present. Returns the empty string if a request ID cannot be found.

func NewLogger

func NewLogger() func(next http.Handler) http.Handler

NewLogger creates a new RequestLogger Handler.

func RequestID

func RequestID(options ...RequestIDOption) func(http.Handler) http.Handler

RequestID is a middleware that injects a request ID into the context of each request.

Types

type LogEntry

type LogEntry struct {
	*Logger
	// contains filtered or unexported fields
}

LogEntry represents an individual log entry.

func (*LogEntry) Panic

func (l *LogEntry) Panic(v interface{}, stack []byte)

Panic prints the call stack for a panic.

func (*LogEntry) Write

func (l *LogEntry) Write(status, totalBytes int, header http.Header, elapsed time.Duration, extra interface{})

Write constructs and writes the final log entry.

type Logger

type Logger struct {
	Logger middleware.LoggerInterface
}

Logger is a middleware that logs useful data about each HTTP request.

func (*Logger) NewLogEntry

func (l *Logger) NewLogEntry(r *http.Request) middleware.LogEntry

NewLogEntry creates a new LogEntry for the request.

type RequestIDOption

type RequestIDOption func(*RequestIDOptions) *RequestIDOptions

func UseXRequestIDHeaderOption

func UseXRequestIDHeaderOption(f bool) RequestIDOption

func XRequestIDLimitOption

func XRequestIDLimitOption(limit int) RequestIDOption

type RequestIDOptions

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

func (*RequestIDOptions) UseRequestID

func (o *RequestIDOptions) UseRequestID() bool

Jump to

Keyboard shortcuts

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