1
0
mirror of https://github.com/labstack/echo.git synced 2025-11-25 22:32:23 +02:00

Proxy middleware refactor

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2017-06-15 08:19:18 -07:00
parent e827c85dc5
commit e1e3ebe5a1
3 changed files with 25 additions and 10 deletions

View File

@@ -55,15 +55,13 @@ func TestProxy(t *testing.T) {
URL: url2,
},
}
config := ProxyConfig{
Balancer: &RandomBalancer{
Targets: targets,
},
rb := &RandomBalancer{
Targets: targets,
}
// Random
e := echo.New()
e.Use(Proxy(config))
e.Use(Proxy(rb))
req := httptest.NewRequest(echo.GET, "/", nil)
rec := newCloseNotifyRecorder()
e.ServeHTTP(rec, req)
@@ -77,11 +75,11 @@ func TestProxy(t *testing.T) {
})
// Round-robin
config.Balancer = &RoundRobinBalancer{
rrb := &RoundRobinBalancer{
Targets: targets,
}
e = echo.New()
e.Use(Proxy(config))
e.Use(Proxy(rrb))
rec = newCloseNotifyRecorder()
e.ServeHTTP(rec, req)
body = rec.Body.String()