From 37ad7dc626602a8355801da6acd85155655520f8 Mon Sep 17 00:00:00 2001 From: antoine Date: Tue, 19 Jan 2016 00:01:23 +0000 Subject: [PATCH 1/8] bump the Go version to test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d44db9f..f2ea74d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ language: go go: - 1.3 - 1.4 - - 1.5.2 + - 1.5.3 From dea43f52281de5022cd0718930f60b89dab2a683 Mon Sep 17 00:00:00 2001 From: Matthew Schick Date: Wed, 6 Apr 2016 23:26:23 -0400 Subject: [PATCH 2/8] Use net.SplitHostPort so ipv6 addresses get parsed properly --- rest/access_log_apache.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest/access_log_apache.go b/rest/access_log_apache.go index 72761f8..e38b8ca 100644 --- a/rest/access_log_apache.go +++ b/rest/access_log_apache.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "log" + "net" "os" "strings" "text/template" @@ -195,8 +196,9 @@ func (u *accessLogUtil) StartTime() *time.Time { func (u *accessLogUtil) ApacheRemoteAddr() string { remoteAddr := u.R.RemoteAddr if remoteAddr != "" { - parts := strings.SplitN(remoteAddr, ":", 2) - return parts[0] + if ip, _, err := net.SplitHostPort(remoteAddr); err == nil { + return ip + } } return "" } From 1c6dbaaf3c0a6bdae4a19f7b0b322a886a56e203 Mon Sep 17 00:00:00 2001 From: antoine Date: Sun, 10 Apr 2016 22:07:21 +0000 Subject: [PATCH 3/8] Ask Travis to test with Go1.6 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f2ea74d..0343061 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,3 +4,4 @@ go: - 1.3 - 1.4 - 1.5.3 + - 1.6 From 0b89f68216f29f0fdb2ef236c2168e3c817d5884 Mon Sep 17 00:00:00 2001 From: antoine Date: Sun, 10 Apr 2016 22:47:58 +0000 Subject: [PATCH 4/8] Fix Apache microsecond logging The ResponseTime may not be available if the timer middleware is not included in the stack. Handle the nil pointer. --- rest/access_log_apache.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest/access_log_apache.go b/rest/access_log_apache.go index e38b8ca..d82894a 100644 --- a/rest/access_log_apache.go +++ b/rest/access_log_apache.go @@ -132,7 +132,10 @@ func (mw *AccessLogApacheMiddleware) convertFormat() { return fmt.Sprintf("%d", value) }, "microseconds": func(dur *time.Duration) string { - return fmt.Sprintf("%d", dur.Nanoseconds()/1000) + if dur != nil { + return fmt.Sprintf("%d", dur.Nanoseconds()/1000) + } + return "" }, "statusCodeColor": func(statusCode int) string { if statusCode >= 400 && statusCode < 500 { From cfd0da14df1db088980175e1c3c7e77c11b90718 Mon Sep 17 00:00:00 2001 From: antoine Date: Sun, 1 May 2016 18:27:56 +0000 Subject: [PATCH 5/8] Update Gorm example, the Gorm API has changed. Make the FB field a pointer --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 69a9ced..8979ec1 100644 --- a/README.md +++ b/README.md @@ -556,7 +556,7 @@ type Reminder struct { } type Impl struct { - DB gorm.DB + DB *gorm.DB } func (i *Impl) InitDB() { From 9c33be62e15d98042dadc93efa334a0c69ca425e Mon Sep 17 00:00:00 2001 From: Ivan Kishchenko Date: Tue, 10 May 2016 15:29:53 +0700 Subject: [PATCH 6/8] Close gzip writer --- rest/gzip.go | 6 ++++++ rest/recorder_test.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rest/gzip.go b/rest/gzip.go index 10f4e9d..0fafc05 100644 --- a/rest/gzip.go +++ b/rest/gzip.go @@ -21,6 +21,12 @@ func (mw *GzipMiddleware) MiddlewareFunc(h HandlerFunc) HandlerFunc { canGzip := strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") // client accepts gzip ? writer := &gzipResponseWriter{w, false, canGzip, nil} + defer func() { + // need to close gzip writer + if writer.gzipWriter != nil { + writer.gzipWriter.Close() + } + }() // call the handler with the wrapped writer h(writer, r) } diff --git a/rest/recorder_test.go b/rest/recorder_test.go index c02b846..61c098a 100644 --- a/rest/recorder_test.go +++ b/rest/recorder_test.go @@ -67,7 +67,7 @@ func TestRecorderAndGzipMiddleware(t *testing.T) { } bytesWritten := r.Env["BYTES_WRITTEN"].(int64) // Yes, the gzipped version actually takes more space. - if bytesWritten != 28 { + if bytesWritten != 41 { t.Errorf("BYTES_WRITTEN 28 expected, got %d", bytesWritten) } } From 28f83d71c05db7b40aa3f543df0585bd8f9f5928 Mon Sep 17 00:00:00 2001 From: Ivan Kishchenko Date: Tue, 10 May 2016 19:37:07 +0700 Subject: [PATCH 7/8] Fix test message --- rest/recorder_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/recorder_test.go b/rest/recorder_test.go index 61c098a..ebb07f8 100644 --- a/rest/recorder_test.go +++ b/rest/recorder_test.go @@ -68,7 +68,7 @@ func TestRecorderAndGzipMiddleware(t *testing.T) { bytesWritten := r.Env["BYTES_WRITTEN"].(int64) // Yes, the gzipped version actually takes more space. if bytesWritten != 41 { - t.Errorf("BYTES_WRITTEN 28 expected, got %d", bytesWritten) + t.Errorf("BYTES_WRITTEN 41 expected, got %d", bytesWritten) } } })) From 4f1814e6e38174c46a6cccdda906987d04b735f6 Mon Sep 17 00:00:00 2001 From: antoine Date: Sun, 28 Aug 2016 00:39:24 +0000 Subject: [PATCH 8/8] Update Travis CI to test Go1.7 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0343061..d58668b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,6 @@ language: go go: - 1.3 - 1.4 - - 1.5.3 + - 1.5 - 1.6 + - 1.7