Skip to content

Commit

Permalink
s/util/mutil/
Browse files Browse the repository at this point in the history
"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.
  • Loading branch information
zenazn committed Dec 7, 2014
1 parent 285133e commit 2ca8864
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions web/middleware/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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 != "" {
Expand Down
3 changes: 3 additions & 0 deletions web/mutil/mutil.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package mutil contains various functions that are helpful when writing http
// middleware.
package mutil
6 changes: 3 additions & 3 deletions web/util/writer_proxy.go → web/mutil/writer_proxy.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package util
package mutil

import (
"bufio"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions web/util/util.go

This file was deleted.

0 comments on commit 2ca8864

Please sign in to comment.