Skip to content

Commit

Permalink
fix: keep the existing baseUrl path in helper function
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Hung <chris@iotechsys.com>
  • Loading branch information
Chris Hung committed Oct 19, 2022
1 parent f0bb5ca commit abc04af
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions clients/http/utils/common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2020-2021 IOTech Ltd
// Copyright (C) 2020-2022 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -15,6 +15,7 @@ import (
"mime/multipart"
"net/http"
"net/url"
"path"
"path/filepath"

"github.com/edgexfoundry/go-mod-core-contracts/v2/common"
Expand Down Expand Up @@ -70,7 +71,7 @@ func createRequest(ctx context.Context, httpMethod string, baseUrl string, reque
if err != nil {
return nil, errors.NewCommonEdgeX(errors.KindServerError, "fail to parse baseUrl", err)
}
u.Path = requestPath
u.Path = path.Join(u.Path, requestPath)
if requestParams != nil {
u.RawQuery = requestParams.Encode()
}
Expand All @@ -87,7 +88,7 @@ func createRequestWithRawDataAndParams(ctx context.Context, httpMethod string, b
if err != nil {
return nil, errors.NewCommonEdgeX(errors.KindServerError, "fail to parse baseUrl", err)
}
u.Path = requestPath
u.Path = path.Join(u.Path, requestPath)
if requestParams != nil {
u.RawQuery = requestParams.Encode()
}
Expand Down Expand Up @@ -115,7 +116,7 @@ func createRequestWithRawData(ctx context.Context, httpMethod string, baseUrl st
if err != nil {
return nil, errors.NewCommonEdgeX(errors.KindServerError, "fail to parse baseUrl", err)
}
u.Path = requestPath
u.Path = path.Join(u.Path, requestPath)
if requestParams != nil {
u.RawQuery = requestParams.Encode()
}
Expand Down Expand Up @@ -144,7 +145,7 @@ func createRequestWithEncodedData(ctx context.Context, httpMethod string, baseUr
if err != nil {
return nil, errors.NewCommonEdgeX(errors.KindServerError, "fail to parse baseUrl", err)
}
u.Path = requestPath
u.Path = path.Join(u.Path, requestPath)

content := encoding
if content == "" {
Expand All @@ -166,7 +167,7 @@ func createRequestFromFilePath(ctx context.Context, httpMethod string, baseUrl s
if err != nil {
return nil, errors.NewCommonEdgeX(errors.KindServerError, "fail to parse baseUrl", err)
}
u.Path = requestPath
u.Path = path.Join(u.Path, requestPath)

fileContents, err := ioutil.ReadFile(filePath)
if err != nil {
Expand Down

0 comments on commit abc04af

Please sign in to comment.