Skip to content

Commit

Permalink
Update to echo/v4 (#9)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
im-kulikov authored and vishr committed Feb 20, 2019
1 parent 4aaa9fa commit 7fa08ff
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 220 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: go
go:
- 1.8.x
- 1.9.x
- 1.11.x
- tip
env:
- GO111MODULE=on
install:
- make dependency
script:
Expand Down
159 changes: 0 additions & 159 deletions Gopkg.lock

This file was deleted.

46 changes: 0 additions & 46 deletions Gopkg.toml

This file was deleted.

3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
dependency:
go get -u github.com/golang/dep/cmd/dep
dep ensure
go mod download

test:
echo "" > coverage.txt
Expand Down
8 changes: 4 additions & 4 deletions casbin/casbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Simple example:
import (
"github.com/casbin/casbin"
"github.com/labstack/echo"
"github.com/labstack/echo/v4"
"github.com/labstack/echo-contrib/casbin" casbin-mw
)
Expand All @@ -25,7 +25,7 @@ Advanced example:
import (
"github.com/casbin/casbin"
"github.com/labstack/echo"
"github.com/labstack/echo/v4"
"github.com/labstack/echo-contrib/casbin" casbin-mw
)
Expand All @@ -46,8 +46,8 @@ package casbin

import (
"github.com/casbin/casbin"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion casbin/casbin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/casbin/casbin"
"github.com/labstack/echo"
"github.com/labstack/echo/v4"
)

func testRequest(t *testing.T, ce *casbin.Enforcer, user string, path string, method string, code int) {
Expand Down
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/labstack/echo-contrib

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

type (
Expand Down
10 changes: 6 additions & 4 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/gorilla/sessions"
"github.com/labstack/echo"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
)

Expand All @@ -19,7 +19,9 @@ func TestMiddleware(t *testing.T) {
sess, _ := Get("test", c)
sess.Options.Domain = "labstack.com"
sess.Values["foo"] = "bar"
sess.Save(c.Request(), c.Response())
if err := sess.Save(c.Request(), c.Response()); err != nil {
return err
}
return c.String(http.StatusOK, "test")
}
store := sessions.NewCookieStore([]byte("secret"))
Expand All @@ -33,7 +35,7 @@ func TestMiddleware(t *testing.T) {
// Skipper
mw := MiddlewareWithConfig(config)
h := mw(echo.NotFoundHandler)
h(c)
assert.Error(t, h(c)) // 404
assert.Nil(t, c.Get(key))

// Panic
Expand All @@ -46,6 +48,6 @@ func TestMiddleware(t *testing.T) {
// Core
mw = Middleware(store)
h = mw(handler)
h(c)
assert.NoError(t, h(c))
assert.Contains(t, rec.Header().Get(echo.HeaderSetCookie), "labstack.com")
}

0 comments on commit 7fa08ff

Please sign in to comment.