Hello everyone,
I'm trying to print a log on every http request like this:
date [url] - httpstatus
And I construct my own http.Handler like this:
type WrapHTTPHandler struct {
m *http.Handler
}
func (h *WrapHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.m.ServeHTTP(w, r)
log.Printf("[%s] %s\n", r.RemoteAddr, r.URL)
}
But I couldn't find out how to get the http status code.
Seems the status code is written directly to the response body, and there is no status code stored in http.Header, is it possible to get the status code here?
Thanks,
Jackie