Skip to content

Commit

Permalink
Upgraded to Echo v4
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <vr@labstack.com>
  • Loading branch information
vishr committed Jun 17, 2019
1 parent 40c3a61 commit fa17c18
Show file tree
Hide file tree
Showing 23 changed files with 151 additions and 125 deletions.
1 change: 0 additions & 1 deletion _fixture/config/1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ hosts:
targets:
- name: cloud
url: http://localhost:9090

2 changes: 1 addition & 1 deletion admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package admin
import (
"github.com/labstack/armor"
"github.com/labstack/armor/admin/api"
"github.com/labstack/echo"
"github.com/labstack/echo/v4"
)

func loadPlugins(a *armor.Armor) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion admin/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"github.com/labstack/armor"
"github.com/labstack/armor/store"
"github.com/labstack/echo"
"github.com/labstack/echo/v4"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion admin/api/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"net/http"

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

type (
Expand Down
2 changes: 1 addition & 1 deletion admin/api/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/labstack/armor/plugin"
"github.com/labstack/armor/store"
"github.com/labstack/armor/util"
"github.com/labstack/echo"
"github.com/labstack/echo/v4"
)

func decodePath(c echo.Context) string {
Expand Down
19 changes: 7 additions & 12 deletions armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/labstack/armor/plugin"
"github.com/labstack/armor/store"
"github.com/labstack/armor/util"
"github.com/labstack/echo"
"github.com/labstack/echo/v4"
"github.com/labstack/gommon/color"
"github.com/labstack/gommon/log"
)
Expand Down Expand Up @@ -76,7 +76,7 @@ type (
RawPlugins []plugin.RawPlugin `json:"plugins"`
Paths Paths `json:"paths"`
Plugins []plugin.Plugin `json:"-"`
Echo *echo.Echo `json:"-"`
Group *echo.Group `json:"-"`
ClientCAs []string `json:"client_ca"`
TLSConfig *tls.Config `json:"-"`
}
Expand Down Expand Up @@ -119,9 +119,8 @@ func (a *Armor) FindHost(name string, add bool) (h *Host) {
// Initialize host
if !h.initialized {
h.Paths = make(Paths)
h.Echo = echo.New()
h.Group = a.Echo.Host(name)
h.Name = name
h.Echo.Logger = a.Logger
h.initialized = true
}

Expand Down Expand Up @@ -162,7 +161,7 @@ func (a *Armor) LoadPlugin(p *store.Plugin, update bool) {
} else if p.Host != "" && p.Path == "" {
// Host level
host := a.FindHost(p.Host, true)
p := plugin.Decode(p.Raw, host.Echo, a.Logger)
p := plugin.Decode(p.Raw, a.Echo, a.Logger)
p.Initialize()
if update {
host.UpdatePlugin(p)
Expand All @@ -173,7 +172,7 @@ func (a *Armor) LoadPlugin(p *store.Plugin, update bool) {
// Path level
host := a.FindHost(p.Host, true)
path := host.FindPath(p.Path)
p := plugin.Decode(p.Raw, host.Echo, a.Logger)
p := plugin.Decode(p.Raw, a.Echo, a.Logger)
p.Initialize()
if update {
path.UpdatePlugin(p)
Expand Down Expand Up @@ -251,7 +250,7 @@ func (h *Host) FindPath(name string) (p *Path) {
// Initialize path
if !p.initialized {
p.Name = name
p.Group = h.Echo.Group(name)
p.Group = h.Group.Group(name)
p.initialized = true
}

Expand All @@ -261,11 +260,7 @@ func (h *Host) FindPath(name string) (p *Path) {
func (h *Host) AddPlugin(p plugin.Plugin) {
h.mutex.Lock()
defer h.mutex.Unlock()
if p.Priority() < 0 {
h.Echo.Pre(p.Process)
} else {
h.Echo.Use(p.Process)
}
h.Group.Use(p.Process)
h.Plugins = append(h.Plugins, p)
}

Expand Down
38 changes: 14 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
module github.com/labstack/armor

go 1.12

require (
github.com/Knetic/govaluate v3.0.0+incompatible
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/asdine/storm v2.1.2+incompatible
github.com/coreos/etcd v3.3.10+incompatible // indirect
github.com/coreos/go-semver v0.2.0 // indirect
github.com/docker/libkv v0.2.1
github.com/ghodss/yaml v1.0.0
github.com/go-sql-driver/mysql v1.4.1 // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-msgpack v0.0.0-20150518234257-fa3f63826f7c // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 // indirect
github.com/hashicorp/consul/api v1.1.0 // indirect
github.com/hashicorp/logutils v1.0.0
github.com/hashicorp/memberlist v0.1.0 // indirect
github.com/hashicorp/serf v0.8.1
github.com/hashicorp/serf v0.8.3
github.com/jmoiron/sqlx v1.2.0
github.com/labstack/echo v3.3.8+incompatible
github.com/labstack/gommon v0.2.8
github.com/labstack/echo v3.3.10+incompatible // indirect
github.com/labstack/echo/v4 v4.1.6
github.com/labstack/gommon v0.2.9
github.com/labstack/tunnel-client v0.2.12
github.com/lib/pq v1.0.0
github.com/miekg/dns v1.0.15 // indirect
github.com/mitchellh/go-homedir v1.0.0
github.com/lib/pq v1.1.1
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.1.2
github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3 // indirect
github.com/stretchr/testify v1.2.2
github.com/ugorji/go/codec v0.0.0-20181120210156-7d13b37dbec6 // indirect
github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4
go.etcd.io/bbolt v1.3.0 // indirect
golang.org/x/crypto v0.0.0-20181106171534-e4dc69e5b2fd
gopkg.in/resty.v1 v1.10.2 // indirect
github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.3.0
github.com/valyala/fasttemplate v1.0.1
go.etcd.io/bbolt v1.3.3 // indirect
golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56
)
Loading

0 comments on commit fa17c18

Please sign in to comment.