added round_robin, least_conn and ip_hash load balance support, small refactoring

This commit is contained in:
yusing
2024-10-09 10:39:07 +08:00
parent 1797896fa6
commit 5c40f4aa84
24 changed files with 739 additions and 64 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/yusing/go-proxy/internal/common"
E "github.com/yusing/go-proxy/internal/error"
gphttp "github.com/yusing/go-proxy/internal/net/http"
"github.com/yusing/go-proxy/internal/net/types"
)
//go:embed test_data/sample_headers.json
@@ -110,7 +111,7 @@ func newMiddlewareTest(middleware *Middleware, args *testArgs) (*TestResult, E.N
} else {
proxyURL, _ = url.Parse("https://" + testHost) // dummy url, no actual effect
}
rp := gphttp.NewReverseProxy(proxyURL, rr)
rp := gphttp.NewReverseProxy(types.NewURL(proxyURL), rr)
mid, setOptErr := middleware.WithOptionsClone(args.middlewareOpt)
if setOptErr != nil {
return nil, setOptErr