From 02deffb33895bd106566dbd42a46ffb9a47474ae Mon Sep 17 00:00:00 2001 From: Umputun Date: Mon, 12 Feb 2018 01:10:34 -0600 Subject: [PATCH] ping chi version --- Gopkg.lock | 6 +-- Gopkg.toml | 2 +- .../go-chi/chi/middleware/logger.go | 40 +++++++++---------- .../go-chi/chi/middleware/terminal.go | 6 +-- .../go-chi/chi/middleware/wrap_writer.go | 6 --- 5 files changed, 25 insertions(+), 35 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index fb7dfe2f..2110ee1f 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -37,13 +37,13 @@ revision = "6ab5f3083f3d925e1944d58cdaebf43bbbff9238" [[projects]] - branch = "master" name = "github.com/go-chi/chi" packages = [ ".", "middleware" ] - revision = "e223a795a06a5598451cf022558c17c779f5a7ab" + revision = "e83ac2304db3c50cf03d96a2fcd39009d458bc35" + version = "v3.3.2" [[projects]] name = "github.com/go-chi/render" @@ -195,6 +195,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "a236f3e2f3ef27b096361283719cdc2d9b712b4923a754f661d6057cef545d69" + inputs-digest = "64f6f97f932d2714aa7eb0b94e94bb555feb5ab9c33673a7731103f4cee9157f" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index ecb92105..2ce75caa 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,6 +1,6 @@ [[constraint]] - branch = "master" name = "github.com/go-chi/chi" + version = "3.0.0" [[constraint]] name = "github.com/go-chi/render" diff --git a/vendor/github.com/go-chi/chi/middleware/logger.go b/vendor/github.com/go-chi/chi/middleware/logger.go index 9f119d56..99fac03d 100644 --- a/vendor/github.com/go-chi/chi/middleware/logger.go +++ b/vendor/github.com/go-chi/chi/middleware/logger.go @@ -16,7 +16,7 @@ var ( // DefaultLogger is called by the Logger middleware handler to log each request. // Its made a package-level variable so that it can be reconfigured for custom // logging configurations. - DefaultLogger = RequestLogger(&DefaultLogFormatter{Logger: log.New(os.Stdout, "", log.LstdFlags), NoColor: false}) + DefaultLogger = RequestLogger(&DefaultLogFormatter{Logger: log.New(os.Stdout, "", log.LstdFlags)}) ) // Logger is a middleware that logs the start and end of each request, along @@ -81,32 +81,29 @@ type LoggerInterface interface { // DefaultLogFormatter is a simple logger that implements a LogFormatter. type DefaultLogFormatter struct { - Logger LoggerInterface - NoColor bool + Logger LoggerInterface } // NewLogEntry creates a new LogEntry for the request. func (l *DefaultLogFormatter) NewLogEntry(r *http.Request) LogEntry { - useColor := !l.NoColor entry := &defaultLogEntry{ DefaultLogFormatter: l, request: r, buf: &bytes.Buffer{}, - useColor: useColor, } reqID := GetReqID(r.Context()) if reqID != "" { - cW(entry.buf, useColor, nYellow, "[%s] ", reqID) + cW(entry.buf, nYellow, "[%s] ", reqID) } - cW(entry.buf, useColor, nCyan, "\"") - cW(entry.buf, useColor, bMagenta, "%s ", r.Method) + cW(entry.buf, nCyan, "\"") + cW(entry.buf, bMagenta, "%s ", r.Method) scheme := "http" if r.TLS != nil { scheme = "https" } - cW(entry.buf, useColor, nCyan, "%s://%s%s %s\" ", scheme, r.Host, r.RequestURI, r.Proto) + cW(entry.buf, nCyan, "%s://%s%s %s\" ", scheme, r.Host, r.RequestURI, r.Proto) entry.buf.WriteString("from ") entry.buf.WriteString(r.RemoteAddr) @@ -117,34 +114,33 @@ func (l *DefaultLogFormatter) NewLogEntry(r *http.Request) LogEntry { type defaultLogEntry struct { *DefaultLogFormatter - request *http.Request - buf *bytes.Buffer - useColor bool + request *http.Request + buf *bytes.Buffer } func (l *defaultLogEntry) Write(status, bytes int, elapsed time.Duration) { switch { case status < 200: - cW(l.buf, l.useColor, bBlue, "%03d", status) + cW(l.buf, bBlue, "%03d", status) case status < 300: - cW(l.buf, l.useColor, bGreen, "%03d", status) + cW(l.buf, bGreen, "%03d", status) case status < 400: - cW(l.buf, l.useColor, bCyan, "%03d", status) + cW(l.buf, bCyan, "%03d", status) case status < 500: - cW(l.buf, l.useColor, bYellow, "%03d", status) + cW(l.buf, bYellow, "%03d", status) default: - cW(l.buf, l.useColor, bRed, "%03d", status) + cW(l.buf, bRed, "%03d", status) } - cW(l.buf, l.useColor, bBlue, " %dB", bytes) + cW(l.buf, bBlue, " %dB", bytes) l.buf.WriteString(" in ") if elapsed < 500*time.Millisecond { - cW(l.buf, l.useColor, nGreen, "%s", elapsed) + cW(l.buf, nGreen, "%s", elapsed) } else if elapsed < 5*time.Second { - cW(l.buf, l.useColor, nYellow, "%s", elapsed) + cW(l.buf, nYellow, "%s", elapsed) } else { - cW(l.buf, l.useColor, nRed, "%s", elapsed) + cW(l.buf, nRed, "%s", elapsed) } l.Logger.Print(l.buf.String()) @@ -152,7 +148,7 @@ func (l *defaultLogEntry) Write(status, bytes int, elapsed time.Duration) { func (l *defaultLogEntry) Panic(v interface{}, stack []byte) { panicEntry := l.NewLogEntry(l.request).(*defaultLogEntry) - cW(panicEntry.buf, l.useColor, bRed, "panic: %+v", v) + cW(panicEntry.buf, bRed, "panic: %+v", v) l.Logger.Print(panicEntry.buf.String()) l.Logger.Print(string(stack)) } diff --git a/vendor/github.com/go-chi/chi/middleware/terminal.go b/vendor/github.com/go-chi/chi/middleware/terminal.go index a5d42410..79930a25 100644 --- a/vendor/github.com/go-chi/chi/middleware/terminal.go +++ b/vendor/github.com/go-chi/chi/middleware/terminal.go @@ -52,12 +52,12 @@ func init() { } // colorWrite -func cW(w io.Writer, useColor bool, color []byte, s string, args ...interface{}) { - if isTTY && useColor { +func cW(w io.Writer, color []byte, s string, args ...interface{}) { + if isTTY { w.Write(color) } fmt.Fprintf(w, s, args...) - if isTTY && useColor { + if isTTY { w.Write(reset) } } diff --git a/vendor/github.com/go-chi/chi/middleware/wrap_writer.go b/vendor/github.com/go-chi/chi/middleware/wrap_writer.go index e49fa5be..5d1c286b 100644 --- a/vendor/github.com/go-chi/chi/middleware/wrap_writer.go +++ b/vendor/github.com/go-chi/chi/middleware/wrap_writer.go @@ -83,8 +83,6 @@ type flushWriter struct { } func (f *flushWriter) Flush() { - f.wroteHeader = true - fl := f.basicWriter.ResponseWriter.(http.Flusher) fl.Flush() } @@ -104,8 +102,6 @@ func (f *httpFancyWriter) CloseNotify() <-chan bool { return cn.CloseNotify() } func (f *httpFancyWriter) Flush() { - f.wroteHeader = true - fl := f.basicWriter.ResponseWriter.(http.Flusher) fl.Flush() } @@ -144,8 +140,6 @@ func (f *http2FancyWriter) CloseNotify() <-chan bool { return cn.CloseNotify() } func (f *http2FancyWriter) Flush() { - f.wroteHeader = true - fl := f.basicWriter.ResponseWriter.(http.Flusher) fl.Flush() }