This commit is contained in:
2023-10-22 15:03:08 -04:00
parent 50eeba7961
commit c3f4608db3
2 changed files with 97 additions and 40 deletions

View File

@@ -13,6 +13,7 @@ import (
"net/http"
"net/url"
"os"
"path"
)
// Ensure ScaffoldingProvider satisfies various provider interfaces.
@@ -98,7 +99,7 @@ func (p *ScaffoldingProvider) Configure(ctx context.Context, req provider.Config
customTransport := &CustomTransport{
Transport: http.DefaultTransport,
BaseURL: &url.URL{Scheme: "https", Host: endpoint + "/api/v1"},
BaseURL: &url.URL{Scheme: "https", Host: endpoint, Path: "/api/v1"},
Token: apiToken,
}
@@ -133,8 +134,7 @@ func (c *CustomTransport) RoundTrip(req *http.Request) (*http.Response, error) {
req.Header.Add("Authorization", "Bearer "+c.Token)
req.URL.Scheme = c.BaseURL.Scheme
req.URL.Host = c.BaseURL.Host
req.URL.Path = c.BaseURL.Path + req.URL.Path
req.URL.Path = path.Join(c.BaseURL.Path, req.URL.Path)
return c.Transport.RoundTrip(req)
}