Skip to content

Commit 7fa08ff

Browse files
im-kulikovvishr
authored andcommitted
Update to echo/v4 (#9)
* Update to echo/v4 - add go modules - fix unhandled errors * update dependencies: - github.com/gorilla/context v1.1.1 - github.com/gorilla/sessions v1.1.3 * fix travis envs
1 parent 4aaa9fa commit 7fa08ff

File tree

10 files changed

+62
-220
lines changed

10 files changed

+62
-220
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
language: go
22
go:
3-
- 1.8.x
4-
- 1.9.x
3+
- 1.11.x
54
- tip
5+
env:
6+
- GO111MODULE=on
67
install:
78
- make dependency
89
script:

Gopkg.lock

Lines changed: 0 additions & 159 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 46 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
dependency:
2-
go get -u github.com/golang/dep/cmd/dep
3-
dep ensure
2+
go mod download
43

54
test:
65
echo "" > coverage.txt

casbin/casbin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Simple example:
66
77
import (
88
"github.com/casbin/casbin"
9-
"github.com/labstack/echo"
9+
"github.com/labstack/echo/v4"
1010
"github.com/labstack/echo-contrib/casbin" casbin-mw
1111
)
1212
@@ -25,7 +25,7 @@ Advanced example:
2525
2626
import (
2727
"github.com/casbin/casbin"
28-
"github.com/labstack/echo"
28+
"github.com/labstack/echo/v4"
2929
"github.com/labstack/echo-contrib/casbin" casbin-mw
3030
)
3131
@@ -46,8 +46,8 @@ package casbin
4646

4747
import (
4848
"github.com/casbin/casbin"
49-
"github.com/labstack/echo"
50-
"github.com/labstack/echo/middleware"
49+
"github.com/labstack/echo/v4"
50+
"github.com/labstack/echo/v4/middleware"
5151
)
5252

5353
type (

casbin/casbin_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/casbin/casbin"
9-
"github.com/labstack/echo"
9+
"github.com/labstack/echo/v4"
1010
)
1111

1212
func testRequest(t *testing.T, ce *casbin.Enforcer, user string, path string, method string, code int) {

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/labstack/echo-contrib
2+
3+
require (
4+
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
5+
github.com/casbin/casbin v1.4.0
6+
github.com/gorilla/context v1.1.1
7+
github.com/gorilla/sessions v1.1.3
8+
github.com/labstack/echo/v4 v4.0.0
9+
github.com/stretchr/testify v1.3.0
10+
)

go.sum

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
github.com/Knetic/govaluate v3.0.0+incompatible h1:7o6+MAPhYTCF0+fdvoz1xDedhRb4f6s9Tn1Tt7/WTEg=
2+
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
3+
github.com/casbin/casbin v1.4.0 h1:TCykTIM1VrxrEsglLtp4cbDHF0GwPU/pjMKxRpRmnJQ=
4+
github.com/casbin/casbin v1.4.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
5+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
6+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7+
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
8+
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
9+
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
10+
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
11+
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
12+
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
13+
github.com/gorilla/sessions v1.1.3 h1:uXoZdcdA5XdXF3QzuSlheVRUvjl+1rKY7zBXL68L9RU=
14+
github.com/gorilla/sessions v1.1.3/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w=
15+
github.com/labstack/echo/v4 v4.0.0 h1:q1GH+caIXPP7H2StPIdzy/ez9CO0EepqYeUg6vi9SWM=
16+
github.com/labstack/echo/v4 v4.0.0/go.mod h1:tZv7nai5buKSg5h/8E6zz4LsD/Dqh9/91Mvs7Z5Zyno=
17+
github.com/labstack/gommon v0.2.8 h1:JvRqmeZcfrHC5u6uVleB4NxxNbzx6gpbJiQknDbKQu0=
18+
github.com/labstack/gommon v0.2.8/go.mod h1:/tj9csK2iPSBvn+3NLM9e52usepMtrd5ilFYA+wQNJ4=
19+
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
20+
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
21+
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
22+
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
23+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
24+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
25+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
26+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
27+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
28+
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
29+
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
30+
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4 h1:gKMu1Bf6QINDnvyZuTaACm9ofY+PRh+5vFz4oxBZeF8=
31+
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw=
32+
golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664 h1:YbZJ76lQ1BqNhVe7dKTSB67wDrc2VPRR75IyGyyPDX8=
33+
golang.org/x/crypto v0.0.0-20190130090550-b01c7a725664/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
34+
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc h1:WiYx1rIFmx8c0mXAFtv5D/mHyKe1+jmuP7PViuwqwuQ=
35+
golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

session/session.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package session
33
import (
44
"github.com/gorilla/context"
55
"github.com/gorilla/sessions"
6-
"github.com/labstack/echo"
7-
"github.com/labstack/echo/middleware"
6+
"github.com/labstack/echo/v4"
7+
"github.com/labstack/echo/v4/middleware"
88
)
99

1010
type (

session/session_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"testing"
77

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

@@ -19,7 +19,9 @@ func TestMiddleware(t *testing.T) {
1919
sess, _ := Get("test", c)
2020
sess.Options.Domain = "labstack.com"
2121
sess.Values["foo"] = "bar"
22-
sess.Save(c.Request(), c.Response())
22+
if err := sess.Save(c.Request(), c.Response()); err != nil {
23+
return err
24+
}
2325
return c.String(http.StatusOK, "test")
2426
}
2527
store := sessions.NewCookieStore([]byte("secret"))
@@ -33,7 +35,7 @@ func TestMiddleware(t *testing.T) {
3335
// Skipper
3436
mw := MiddlewareWithConfig(config)
3537
h := mw(echo.NotFoundHandler)
36-
h(c)
38+
assert.Error(t, h(c)) // 404
3739
assert.Nil(t, c.Get(key))
3840

3941
// Panic
@@ -46,6 +48,6 @@ func TestMiddleware(t *testing.T) {
4648
// Core
4749
mw = Middleware(store)
4850
h = mw(handler)
49-
h(c)
51+
assert.NoError(t, h(c))
5052
assert.Contains(t, rec.Header().Get(echo.HeaderSetCookie), "labstack.com")
5153
}

0 commit comments

Comments
 (0)