A simple HTTP access logger for golang.
Usage:
func AccessLog(cb func(call *accesslog.Call)) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
// before request,install ResponseWriter proxy
call := &accesslog.Call{}
rwProxy := accesslog.NewResponseRecorder(rw, true)
accesslog.Before(call, r)
next.ServeHTTP(rwProxy, r)
// after request and callback
accesslog.After(call, rwProxy, r)
cb(call)
})
}
}