From 8180cc540da127d72a5623b1321bc3e9505f3000 Mon Sep 17 00:00:00 2001 From: hfuss Date: Thu, 19 Dec 2024 21:50:51 -0500 Subject: [PATCH] other edge case of unknown host Signed-off-by: hfuss --- pkg/ffresty/ffresty.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/ffresty/ffresty.go b/pkg/ffresty/ffresty.go index 9774b0f..4b50bde 100644 --- a/pkg/ffresty/ffresty.go +++ b/pkg/ffresty/ffresty.go @@ -29,7 +29,6 @@ import ( "strings" "time" - "github.com/go-resty/resty/v2" "github.com/hyperledger/firefly-common/pkg/config" "github.com/hyperledger/firefly-common/pkg/ffapi" "github.com/hyperledger/firefly-common/pkg/fftypes" @@ -249,8 +248,8 @@ func NewWithConfig(ctx context.Context, ffrestyConfig Config) (client *resty.Cli client.SetTimeout(time.Duration(ffrestyConfig.HTTPRequestTimeout)) - client.OnBeforeRequest(func(_ *resty.Client, req *resty.Request) error { - if rateLimiterMap[client] != nil { + client.OnBeforeRequest(func(c *resty.Client, req *resty.Request) error { + if rateLimiter != nil { // Wait for permission to proceed with the request err := rateLimiterMap[client].Wait(req.Context()) if err != nil { @@ -269,6 +268,9 @@ func NewWithConfig(ctx context.Context, ffrestyConfig Config) (client *resty.Cli if u == nil && _url != "" { u, _ = url.Parse(_url) } + if u == nil && c.BaseURL != "" { + u, _ = url.Parse(c.BaseURL) + } if u != nil && u.Host != "" { host := u.Host rCtx = context.WithValue(rCtx, hostCtxKey{}, host)