diff --git a/pkg/server/httplog/BUILD b/pkg/server/httplog/BUILD index 998c9d056..1de39eba9 100644 --- a/pkg/server/httplog/BUILD +++ b/pkg/server/httplog/BUILD @@ -10,7 +10,7 @@ load( go_test( name = "go_default_test", - srcs = ["log_test.go"], + srcs = ["httplog_test.go"], library = ":go_default_library", tags = ["automanaged"], ) @@ -19,7 +19,7 @@ go_library( name = "go_default_library", srcs = [ "doc.go", - "log.go", + "httplog.go", ], tags = ["automanaged"], deps = ["//vendor/github.com/golang/glog:go_default_library"], diff --git a/pkg/server/httplog/log.go b/pkg/server/httplog/httplog.go similarity index 93% rename from pkg/server/httplog/log.go rename to pkg/server/httplog/httplog.go index 4a4894cee..5939ccb04 100644 --- a/pkg/server/httplog/log.go +++ b/pkg/server/httplog/httplog.go @@ -27,18 +27,6 @@ import ( "github.com/golang/glog" ) -// Handler wraps all HTTP calls to delegate with nice logging. -// delegate may use LogOf(w).Addf(...) to write additional info to -// the per-request log message. -// -// Intended to wrap calls to your ServeMux. -func Handler(delegate http.Handler, pred StacktracePred) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - defer NewLogged(req, &w).StacktraceWhen(pred).Log() - delegate.ServeHTTP(w, req) - }) -} - // StacktracePred returns true if a stacktrace should be logged for this status. type StacktracePred func(httpStatus int) (logStacktrace bool) diff --git a/pkg/server/httplog/log_test.go b/pkg/server/httplog/httplog_test.go similarity index 86% rename from pkg/server/httplog/log_test.go rename to pkg/server/httplog/httplog_test.go index 906ec3673..680b1e478 100644 --- a/pkg/server/httplog/log_test.go +++ b/pkg/server/httplog/httplog_test.go @@ -17,7 +17,6 @@ limitations under the License. package httplog import ( - "bytes" "net/http" "net/http/httptest" "reflect" @@ -38,28 +37,6 @@ func TestDefaultStacktracePred(t *testing.T) { } } -func TestHandler(t *testing.T) { - want := &httptest.ResponseRecorder{ - HeaderMap: make(http.Header), - Body: new(bytes.Buffer), - } - want.WriteHeader(http.StatusOK) - mux := http.NewServeMux() - handler := Handler(mux, DefaultStacktracePred) - mux.HandleFunc("/kube", func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - }) - req, err := http.NewRequest("GET", "http://example.com/kube", nil) - if err != nil { - t.Errorf("Unexpected error: %v", err) - } - w := httptest.NewRecorder() - handler.ServeHTTP(w, req) - if !reflect.DeepEqual(want, w) { - t.Errorf("Expected %v, got %v", want, w) - } -} - func TestStatusIsNot(t *testing.T) { statusTestTable := []struct { status int