Documentation ¶
Index ¶
- Constants
- func GetZap(r *http.Request) *zap.Logger
- func GetZapCtx(ctx context.Context) *zap.Logger
- func Recoverer(lvl zapcore.Level, msg string, opts ...OptionRecoverer) func(next http.Handler) http.Handler
- func RecovererDefault(w http.ResponseWriter, _ *http.Request)
- func Request(lvl zapcore.Level, msg string, opts ...OptionRequest) func(next http.Handler) http.Handler
- func WithZap(logger *zap.Logger, opts ...OptionWithZap) func(next http.Handler) http.Handler
- type OptionRecoverer
- type OptionRequest
- type OptionWithZap
- type WrapResponseWriter
Constants ¶
View Source
const ZapKey ctxKeyZap = iota
ZapKey is the key that holds the unique zap logger in a request context.
Variables ¶
This section is empty.
Functions ¶
func Recoverer ¶
func Recoverer(lvl zapcore.Level, msg string, opts ...OptionRecoverer) func(next http.Handler) http.Handler
Recoverer is a middleware that recovers from panics.
func RecovererDefault ¶
func RecovererDefault(w http.ResponseWriter, _ *http.Request)
RecovererDefault writes server error response.
Types ¶
type OptionRecoverer ¶
type OptionRecoverer func(w http.ResponseWriter, r *http.Request)
OptionRecoverer is an option to change error response process.
type OptionRequest ¶
OptionRequest is an option to add fields for request log.
type OptionWithZap ¶
OptionWithZap is an option to add processing to zap logger held in request context.
type WrapResponseWriter ¶
type WrapResponseWriter interface { http.ResponseWriter // Status returns the HTTP status of the request, or 0 if one has not // yet been sent. Status() int // BytesWritten returns the total number of bytes sent to the client. BytesWritten() int // Tee causes the response body to be written to the given io.Writer in // addition to proxying the writes through. Only one io.Writer can be // tee'd to at once: setting a second one will overwrite the first. // Writes will be sent to the proxy before being written to this // io.Writer. It is illegal for the tee'd writer to be modified // concurrently with writes. Tee(io.Writer) // Unwrap returns the original proxied target. Unwrap() http.ResponseWriter }
WrapResponseWriter is a proxy around an http.ResponseWriter that allows you to hook into various parts of the response process.
func NewWrapResponseWriter ¶
func NewWrapResponseWriter(w http.ResponseWriter, protoMajor int) WrapResponseWriter
NewWrapResponseWriter wraps an http.ResponseWriter, returning a proxy that allows you to hook into various parts of the response process.
Click to show internal directories.
Click to hide internal directories.