Issue Description
ProxyWithConfig can panic when the balancer has no targets.
The built-in balancers return nil when their target list is empty. The proxy middleware then passes that nil target to proxyHTTP / proxyRaw, which can panic.
One way to hit this is to remove the last target with RemoveTarget.
I expected the middleware to return a proxy error, such as 502 Bad Gateway, instead of panicking.
Working code to debug
targetURL, _ := url.Parse("http://127.0.0.1:8080")
balancer := middleware.NewRoundRobinBalancer([]*middleware.ProxyTarget{
{Name: "target", URL: targetURL},
})
e := echo.New()
e.Use(middleware.Proxy(balancer))
// Later, from code that updates proxy targets at runtime:
balancer.RemoveTarget("target")
// The next proxied request can panic because the balancer returns nil.
### Version/commit
v4.15.x and v5.1.x
Issue Description
ProxyWithConfigcan panic when the balancer has no targets.The built-in balancers return
nilwhen their target list is empty. The proxy middleware then passes that nil target toproxyHTTP/proxyRaw, which can panic.One way to hit this is to remove the last target with
RemoveTarget.I expected the middleware to return a proxy error, such as
502 Bad Gateway, instead of panicking.Working code to debug