From 50b5d74df2547562466df66c4f9c3d56d36d2580 Mon Sep 17 00:00:00 2001 From: Mathieu CARBONNEAUX Date: Fri, 5 Jul 2024 15:15:48 +0200 Subject: [PATCH 1/2] Add optional config option to change base path of wapi api uri. --- README.md | 1 + connector.go | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 245a61f7..f6ad10a9 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ This library is compatible with Go 1.2+ hostConfig := ibclient.HostConfig{ Scheme: "https", Host: "", + BasePath: "", Version: "", Port: "PORT", } diff --git a/connector.go b/connector.go index 110d116f..b2bfeb8a 100644 --- a/connector.go +++ b/connector.go @@ -28,10 +28,11 @@ type AuthConfig struct { } type HostConfig struct { - Scheme string - Host string - Version string - Port string + Scheme string + Host string + BasePath string + Version string + Port string } type TransportConfig struct { @@ -244,7 +245,12 @@ func (wrb *WapiRequestBuilder) Init(hostCfg HostConfig, authCfg AuthConfig) { } func (wrb *WapiRequestBuilder) BuildUrl(t RequestType, objType string, ref string, returnFields []string, queryParams *QueryParams) (urlStr string) { - path := []string{"wapi", "v" + wrb.hostCfg.Version} + if wrb.hostCfg.BasePath != "" { + path := []string{wrb.hostCfg.BasePath,"wapi", "v" + wrb.hostCfg.Version} + } else { + path := []string{"wapi", "v" + wrb.hostCfg.Version} + } + if len(ref) > 0 { path = append(path, ref) } else { From f6b2a61471e41a0411288a367bd394f55d02cd0a Mon Sep 17 00:00:00 2001 From: CARBONNEAUX Mathieu Date: Wed, 26 Feb 2025 16:26:30 +0100 Subject: [PATCH 2/2] Update connector.go Co-authored-by: Bob van Bokkem --- connector.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/connector.go b/connector.go index b2bfeb8a..8ddf4a41 100644 --- a/connector.go +++ b/connector.go @@ -245,12 +245,10 @@ func (wrb *WapiRequestBuilder) Init(hostCfg HostConfig, authCfg AuthConfig) { } func (wrb *WapiRequestBuilder) BuildUrl(t RequestType, objType string, ref string, returnFields []string, queryParams *QueryParams) (urlStr string) { + path := []string{"wapi", "v" + wrb.hostCfg.Version} if wrb.hostCfg.BasePath != "" { - path := []string{wrb.hostCfg.BasePath,"wapi", "v" + wrb.hostCfg.Version} - } else { - path := []string{"wapi", "v" + wrb.hostCfg.Version} - } - + path = append([]string{wrb.hostCfg.BasePath}, path...) + } if len(ref) > 0 { path = append(path, ref) } else {