FAQ
Hello everyone,

I'm trying to print a log on every http request like this:
date [url] - httpstatus
e.g.: 2012/10/24 15:30:23 [127.0.0.1:56485] / - 200

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

--

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 6 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 24, '12 at 2:42p
activeOct 24, '12 at 7:25p
posts6
users4
websitegolang.org

People

Translate

site design / logo © 2017 Grokbase