Skip to content

Commit 6d9e043

Browse files
committed
Introduced Go module support as v4, removed obsolete CloseNotifier() mechanism
This reintroduces support for Go modules, as v4. CloseNotifier() is removed as it has been obsoleted, see https://golang.org/doc/go1.11#net/http It was already NOT working (not sending signals) as of 1.11 the functionality was gone, we merely deleted the functions that exposed it. If anyone still relies on it they should migrate to using `c.Request().Context().Done()` instead. Closes #1268, #1255
1 parent 282a44d commit 6d9e043

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+107
-94
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,26 @@
44
[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/labstack/echo)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/labstack/echo?style=flat-square)](https://goreportcard.com/report/github.com/labstack/echo)
66
[![Build Status](http://img.shields.io/travis/labstack/echo.svg?style=flat-square)](https://travis-ci.org/labstack/echo)
7-
[![Codecov](https://img.shields.io/codecov/c/github/labstack/echo.svg?style=flat-square)](https://codecov.io/gh/labstack/echo)
7+
[![Codecov](https://img.shields.io/codecov/c/github/labstack/echo.svg?style=flat-square)](https://codecov.io/gh/labstack/echo)
88
[![Join the chat at https://gitter.im/labstack/echo](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg?style=flat-square)](https://gitter.im/labstack/echo)
99
[![Forum](https://img.shields.io/badge/community-forum-00afd1.svg?style=flat-square)](https://forum.labstack.com)
1010
[![Twitter](https://img.shields.io/badge/twitter-@labstack-55acee.svg?style=flat-square)](https://twitter.com/labstack)
1111
[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/labstack/echo/master/LICENSE)
1212

13+
## Supported Go versions
14+
15+
As of version 4.0.0, Echo is available as a [Go module](https://github.com/golang/go/wiki/Modules).
16+
Therefore a Go version capable of understanding /vN suffixed imports is required:
17+
18+
- 1.9.7+
19+
- 1.10.3+
20+
- 1.11+
21+
22+
Any of these versions will allow you to import Echo as `github.com/labstack/echo/v4` which is the recommended
23+
way of using Echo going forward.
24+
25+
For older versions, please use the latest v3 tag.
26+
1327
## Feature Overview
1428

1529
- Optimized HTTP router which smartly prioritize routes
@@ -44,8 +58,8 @@ package main
4458
import (
4559
"net/http"
4660

47-
"github.com/labstack/echo"
48-
"github.com/labstack/echo/middleware"
61+
"github.com/labstack/echo/v4"
62+
"github.com/labstack/echo/v4/middleware"
4963
)
5064

5165
func main() {
@@ -90,6 +104,7 @@ func hello(c echo.Context) error {
90104
- Improve/fix documentation
91105

92106
## Credits
107+
93108
- [Vishal Rana](https://github.com/vishr) - Author
94109
- [Nitin Rana](https://github.com/nr17) - Consultant
95110
- [Contributors](https://github.com/labstack/echo/graphs/contributors)

echo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Example:
88
import (
99
"net/http"
1010
11-
"github.com/labstack/echo"
12-
"github.com/labstack/echo/middleware"
11+
"github.com/labstack/echo/v4"
12+
"github.com/labstack/echo/v4/middleware"
1313
)
1414
1515
// Handler
@@ -221,7 +221,7 @@ const (
221221

222222
const (
223223
// Version of Echo
224-
Version = "3.3.11-dev"
224+
Version = "4.0.0"
225225
website = "https://echo.labstack.com"
226226
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
227227
banner = `

go.mod

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module github.com/labstack/echo/v4
2+
3+
require (
4+
github.com/dgrijalva/jwt-go v3.2.0+incompatible
5+
github.com/labstack/gommon v0.2.8
6+
github.com/mattn/go-colorable v0.0.9 // indirect
7+
github.com/mattn/go-isatty v0.0.4 // indirect
8+
github.com/stretchr/testify v1.3.0
9+
github.com/valyala/bytebufferpool v1.0.0 // indirect
10+
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4
11+
golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664
12+
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc // indirect
13+
)

go.sum

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
4+
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
5+
github.com/labstack/gommon v0.2.8 h1:JvRqmeZcfrHC5u6uVleB4NxxNbzx6gpbJiQknDbKQu0=
6+
github.com/labstack/gommon v0.2.8/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4=
7+
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
8+
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
9+
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
10+
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
11+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
12+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
13+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
14+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
15+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
16+
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
17+
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
18+
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 h1:gKMu1Bf6QINDnvyZuTaACm9ofY+PRh+5vFz4oxBZeF8=
19+
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw=
20+
golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664 h1:YbZJ76lQ1BqNhVe7dKTSB67wDrc2VPRR75IyGyyPDX8=
21+
golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
22+
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc h1:WiYx1rIFmx8c0mXAFtv5D/mHyKe1+jmuP7PViuwqwuQ=
23+
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

middleware/basic_auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strconv"
66
"strings"
77

8-
"github.com/labstack/echo"
8+
"github.com/labstack/echo/v4"
99
)
1010

1111
type (

middleware/basic_auth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"testing"
99

10-
"github.com/labstack/echo"
10+
"github.com/labstack/echo/v4"
1111
"github.com/stretchr/testify/assert"
1212
)
1313

middleware/body_dump.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"net"
99
"net/http"
1010

11-
"github.com/labstack/echo"
11+
"github.com/labstack/echo/v4"
1212
)
1313

1414
type (
@@ -105,7 +105,3 @@ func (w *bodyDumpResponseWriter) Flush() {
105105
func (w *bodyDumpResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
106106
return w.ResponseWriter.(http.Hijacker).Hijack()
107107
}
108-
109-
func (w *bodyDumpResponseWriter) CloseNotify() <-chan bool {
110-
return w.ResponseWriter.(http.CloseNotifier).CloseNotify()
111-
}

middleware/body_dump_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"strings"
99
"testing"
1010

11-
"github.com/labstack/echo"
11+
"github.com/labstack/echo/v4"
1212
"github.com/stretchr/testify/assert"
1313
)
1414

middleware/body_limit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"io"
66
"sync"
77

8-
"github.com/labstack/echo"
8+
"github.com/labstack/echo/v4"
99
"github.com/labstack/gommon/bytes"
1010
)
1111

middleware/body_limit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"net/http/httptest"
88
"testing"
99

10-
"github.com/labstack/echo"
10+
"github.com/labstack/echo/v4"
1111
"github.com/stretchr/testify/assert"
1212
)
1313

middleware/compress.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"strings"
1111

12-
"github.com/labstack/echo"
12+
"github.com/labstack/echo/v4"
1313
)
1414

1515
type (
@@ -116,7 +116,3 @@ func (w *gzipResponseWriter) Flush() {
116116
func (w *gzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
117117
return w.ResponseWriter.(http.Hijacker).Hijack()
118118
}
119-
120-
func (w *gzipResponseWriter) CloseNotify() <-chan bool {
121-
return w.ResponseWriter.(http.CloseNotifier).CloseNotify()
122-
}

middleware/compress_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"net/http/httptest"
99
"testing"
1010

11-
"github.com/labstack/echo"
11+
"github.com/labstack/echo/v4"
1212
"github.com/stretchr/testify/assert"
1313
)
1414

middleware/cors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strconv"
66
"strings"
77

8-
"github.com/labstack/echo"
8+
"github.com/labstack/echo/v4"
99
)
1010

1111
type (

middleware/cors_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"net/http/httptest"
66
"testing"
77

8-
"github.com/labstack/echo"
8+
"github.com/labstack/echo/v4"
99
"github.com/stretchr/testify/assert"
1010
)
1111

middleware/csrf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"time"
99

10-
"github.com/labstack/echo"
10+
"github.com/labstack/echo/v4"
1111
"github.com/labstack/gommon/random"
1212
)
1313

middleware/csrf_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"testing"
99

10-
"github.com/labstack/echo"
10+
"github.com/labstack/echo/v4"
1111
"github.com/labstack/gommon/random"
1212
"github.com/stretchr/testify/assert"
1313
)

middleware/jwt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88

99
"github.com/dgrijalva/jwt-go"
10-
"github.com/labstack/echo"
10+
"github.com/labstack/echo/v4"
1111
)
1212

1313
type (

middleware/jwt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"testing"
77

88
"github.com/dgrijalva/jwt-go"
9-
"github.com/labstack/echo"
9+
"github.com/labstack/echo/v4"
1010
"github.com/stretchr/testify/assert"
1111
)
1212

middleware/key_auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"net/http"
66
"strings"
77

8-
"github.com/labstack/echo"
8+
"github.com/labstack/echo/v4"
99
)
1010

1111
type (

middleware/key_auth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"testing"
99

10-
"github.com/labstack/echo"
10+
"github.com/labstack/echo/v4"
1111
"github.com/stretchr/testify/assert"
1212
)
1313

middleware/logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"sync"
1010
"time"
1111

12-
"github.com/labstack/echo"
12+
"github.com/labstack/echo/v4"
1313
"github.com/labstack/gommon/color"
1414
"github.com/valyala/fasttemplate"
1515
)

middleware/logger_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"time"
1313
"unsafe"
1414

15-
"github.com/labstack/echo"
15+
"github.com/labstack/echo/v4"
1616
"github.com/stretchr/testify/assert"
1717
)
1818

middleware/method_override.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package middleware
33
import (
44
"net/http"
55

6-
"github.com/labstack/echo"
6+
"github.com/labstack/echo/v4"
77
)
88

99
type (

middleware/method_override_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"net/http/httptest"
77
"testing"
88

9-
"github.com/labstack/echo"
9+
"github.com/labstack/echo/v4"
1010
"github.com/stretchr/testify/assert"
1111
)
1212

middleware/middleware.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strconv"
66
"strings"
77

8-
"github.com/labstack/echo"
8+
"github.com/labstack/echo/v4"
99
)
1010

1111
type (

middleware/proxy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"sync/atomic"
1414
"time"
1515

16-
"github.com/labstack/echo"
16+
"github.com/labstack/echo/v4"
1717
)
1818

1919
// TODO: Handle TLS proxy
@@ -37,11 +37,11 @@ type (
3737
// "/users/*/orders/*": "/user/$1/order/$2",
3838
Rewrite map[string]string
3939

40-
// Context key to store selected ProxyTarget into context.
40+
// Context key to store selected ProxyTarget into context.
4141
// Optional. Default value "target".
4242
ContextKey string
4343

44-
// To customize the transport to remote.
44+
// To customize the transport to remote.
4545
// Examples: If custom TLS certificates are required.
4646
Transport http.RoundTripper
4747

middleware/proxy_1_11.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"net/http"
88
"net/http/httputil"
99

10-
"github.com/labstack/echo"
10+
"github.com/labstack/echo/v4"
1111
)
1212

1313
func proxyHTTP(tgt *ProxyTarget, c echo.Context, config ProxyConfig) http.Handler {

middleware/proxy_1_11_n.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
package middleware
44

55
import (
6-
"github.com/labstack/echo"
76
"net/http"
87
"net/http/httputil"
8+
9+
"github.com/labstack/echo/v4"
910
)
1011

1112
func proxyHTTP(t *ProxyTarget, c echo.Context, config ProxyConfig) http.Handler {

middleware/proxy_1_11_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"net/url"
99
"testing"
1010

11-
"github.com/labstack/echo"
11+
"github.com/labstack/echo/v4"
1212
"github.com/stretchr/testify/assert"
1313
)
1414

@@ -42,10 +42,10 @@ func TestProxy_1_11(t *testing.T) {
4242
e := echo.New()
4343
e.Use(Proxy(rb))
4444
req := httptest.NewRequest(http.MethodGet, "/", nil)
45-
rec := newCloseNotifyRecorder()
45+
rec := httptest.NewRecorder()
4646

4747
// Remote unreachable
48-
rec = newCloseNotifyRecorder()
48+
rec = httptest.NewRecorder()
4949
req.URL.Path = "/api/users"
5050
e.ServeHTTP(rec, req)
5151
assert.Equal(t, "/api/users", req.URL.Path)

0 commit comments

Comments
 (0)