Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional config option to change base path of wapi api uri. #239

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ This library is compatible with Go 1.2+
hostConfig := ibclient.HostConfig{
Scheme: "https",
Host: "<NIOS grid IP>",
BasePath: "<Optional uri base path before /wapi path>",
Version: "<WAPI version>",
Port: "PORT",
}
Expand Down
16 changes: 11 additions & 5 deletions connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down