From 2ca8864e18b41cf0cb4ad3beaf317257befed33e Mon Sep 17 00:00:00 2001 From: Carl Jackson Date: Sun, 7 Dec 2014 15:19:13 -0800 Subject: [PATCH] s/util/mutil/ "util" is a really bad name for a package since it isn't very descriptive and so often collides with other names. Unfortunately, this is a breaking change, but it's both very easy to fix and perhaps more importantly also better to do now than later. --- web/middleware/logger.go | 6 +++--- web/mutil/mutil.go | 3 +++ web/{util => mutil}/writer_proxy.go | 6 +++--- web/util/util.go | 3 --- 4 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 web/mutil/mutil.go rename web/{util => mutil}/writer_proxy.go (95%) delete mode 100644 web/util/util.go diff --git a/web/middleware/logger.go b/web/middleware/logger.go index e0fb9aa..8bbcac8 100644 --- a/web/middleware/logger.go +++ b/web/middleware/logger.go @@ -7,7 +7,7 @@ import ( "time" "github.com/zenazn/goji/web" - "github.com/zenazn/goji/web/util" + "github.com/zenazn/goji/web/mutil" ) // Logger is a middleware that logs the start and end of each request, along @@ -29,7 +29,7 @@ func Logger(c *web.C, h http.Handler) http.Handler { printStart(reqID, r) - lw := util.WrapWriter(w) + lw := mutil.WrapWriter(w) t1 := time.Now() h.ServeHTTP(lw, r) @@ -60,7 +60,7 @@ func printStart(reqID string, r *http.Request) { log.Print(buf.String()) } -func printEnd(reqID string, w util.WriterProxy, dt time.Duration) { +func printEnd(reqID string, w mutil.WriterProxy, dt time.Duration) { var buf bytes.Buffer if reqID != "" { diff --git a/web/mutil/mutil.go b/web/mutil/mutil.go new file mode 100644 index 0000000..e8d5b28 --- /dev/null +++ b/web/mutil/mutil.go @@ -0,0 +1,3 @@ +// Package mutil contains various functions that are helpful when writing http +// middleware. +package mutil diff --git a/web/util/writer_proxy.go b/web/mutil/writer_proxy.go similarity index 95% rename from web/util/writer_proxy.go rename to web/mutil/writer_proxy.go index 4406a3c..d572812 100644 --- a/web/util/writer_proxy.go +++ b/web/mutil/writer_proxy.go @@ -1,4 +1,4 @@ -package util +package mutil import ( "bufio" @@ -27,8 +27,8 @@ type WriterProxy interface { Unwrap() http.ResponseWriter } -// WrapWriter wraps an http.ResponseWriter into a proxy that allows you to hook -// into various parts of the response process. +// WrapWriter wraps an http.ResponseWriter, returning a proxy that allows you to +// hook into various parts of the response process. func WrapWriter(w http.ResponseWriter) WriterProxy { _, cn := w.(http.CloseNotifier) _, fl := w.(http.Flusher) diff --git a/web/util/util.go b/web/util/util.go deleted file mode 100644 index aa9dda8..0000000 --- a/web/util/util.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package util contains various functions that are helpful when writing http -// middleware. -package util