Skip to content

crhntr/httplog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

httplog

httplog is a http request logger to wrap your http.Handler.

GoDoc

Example

mux := http.NewServeMux()
mux.HandleFunc("/greeting", func(w http.ResponseWriter, r *http.Request) {
  w.WriteHeader(http.StatusOK)
  fmt.Fprint(w, "Hello, world!")
})
logMux := httplog.Wrap(mux)
w := httptest.NewRecorder()
r := httptest.NewRequest(http.MethodGet, "/greeting", nil)
logMux.ServeHTTP(w, r)
// Output:
// {"type": "HTTP_REQUEST", "method": "GET", "path": "/greeting", "duration": "48.572µs", "status": 200}

About

A simple http request logger

Resources

License

Stars

Watchers

Forks

Languages