diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:15:20 +0000 |
commit | 87d772a7d708fec12f48cd8adc0dedff6e1025da (patch) | |
tree | 1fee344c64cc3f43074a01981e21126c8482a522 /src/go/collectors/go.d.plugin/pkg/web/request.go | |
parent | Adding upstream version 1.46.3. (diff) | |
download | netdata-upstream.tar.xz netdata-upstream.zip |
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/go/plugin/go.d/pkg/web/request.go (renamed from src/go/collectors/go.d.plugin/pkg/web/request.go) | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/go/collectors/go.d.plugin/pkg/web/request.go b/src/go/plugin/go.d/pkg/web/request.go index e8e4b742a..20a6ec093 100644 --- a/src/go/collectors/go.d.plugin/pkg/web/request.go +++ b/src/go/plugin/go.d/pkg/web/request.go @@ -7,10 +7,11 @@ import ( "fmt" "io" "net/http" + "net/url" "strings" - "github.com/netdata/netdata/go/go.d.plugin/agent/executable" - "github.com/netdata/netdata/go/go.d.plugin/pkg/buildinfo" + "github.com/netdata/netdata/go/plugins/pkg/buildinfo" + "github.com/netdata/netdata/go/plugins/pkg/executable" ) // Request is the configuration of the HTTP request. @@ -90,3 +91,15 @@ func NewHTTPRequest(cfg Request) (*http.Request, error) { return req, nil } + +func NewHTTPRequestWithPath(cfg Request, urlPath string) (*http.Request, error) { + cfg = cfg.Copy() + + v, err := url.JoinPath(cfg.URL, urlPath) + if err != nil { + return nil, fmt.Errorf("failed to join URL path: %v", err) + } + cfg.URL = v + + return NewHTTPRequest(cfg) +} |