zerolog icon indicating copy to clipboard operation
zerolog copied to clipboard

When using hlog.AccessHandler, HTTP2 pushing gets disabled

Open mitar opened this issue 2 years ago • 2 comments

Because w.(http.Pusher) fails. It looks like mutil.WrapWriter does not implement it.

mitar avatar Feb 23 '22 23:02 mitar

I think it might be useful to switch mutil.WrapWriter to https://github.com/felixge/httpsnoop.

mitar avatar Feb 23 '22 23:02 mitar

It looks trivial to replace it:

func AccessHandler(f func(req *http.Request, code int, size int64, duration time.Duration)) func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			m := httpsnoop.CaptureMetrics(next, w, req)
			f(req, m.Code, m.Written, m.Duration)
		})
	}
}

mitar avatar Feb 23 '22 23:02 mitar