Skip to content

Commit

Permalink
Update HostConfig with Scheme (infobloxopen#216)
Browse files Browse the repository at this point in the history
* Update HostConfig with configurable Scheme

* if scheme is not http then use the default scheme https
  • Loading branch information
smalisetti-infoblox authored Jan 4, 2024
1 parent 6caaa01 commit c6208bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ This library is compatible with Go 1.2+

func main() {
hostConfig := ibclient.HostConfig{
Scheme: "https",
Host: "<NIOS grid IP>",
Version: "<WAPI version>",
Port: "PORT",
Expand Down
7 changes: 6 additions & 1 deletion connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type AuthConfig struct {
}

type HostConfig struct {
Scheme string
Host string
Version string
Port string
Expand Down Expand Up @@ -250,8 +251,12 @@ func (wrb *WapiRequestBuilder) BuildUrl(t RequestType, objType string, ref strin
qry = vals.Encode()
}

scheme := "https"
if wrb.hostCfg.Scheme == "http" {
scheme = "http"
}
u := url.URL{
Scheme: "https",
Scheme: scheme,
Host: wrb.hostCfg.Host + ":" + wrb.hostCfg.Port,
Path: strings.Join(path, "/"),
RawQuery: qry,
Expand Down

0 comments on commit c6208bb

Please sign in to comment.