From cc2ac0591a77d9715ee501118669602a1f01dd85 Mon Sep 17 00:00:00 2001 From: Ed Lynes Date: Fri, 3 Apr 2020 17:44:25 -0400 Subject: [PATCH] correct GetRecordsets qarg processing --- configdns-v2/record_lookup.go | 44 +++++++++++++++-------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/configdns-v2/record_lookup.go b/configdns-v2/record_lookup.go index 7b89cae6..dcc2c8b2 100644 --- a/configdns-v2/record_lookup.go +++ b/configdns-v2/record_lookup.go @@ -140,42 +140,36 @@ func GetRecordsets(zone string, queryArgs ...RecordsetQueryArgs) (*RecordSetResp if len(queryArgs) > 1 { return nil, errors.New("GetRecordsets QueryArgs invalid.") } + + req, err := client.NewRequest( + Config, + "GET", + getURL, + nil, + ) + if err != nil { + return nil, err + } + + q := req.URL.Query() if len(queryArgs) > 0 { - getURL += "?" if queryArgs[0].Page > 0 { - getURL += fmt.Sprintf("page=%d", queryArgs[0].Page) - getURL += "&" + q.Add("page", strconv.Itoa(queryArgs[0].Page)) } if queryArgs[0].PageSize > 0 { - getURL += fmt.Sprintf("pageSize=%d", queryArgs[0].PageSize) - getURL += "&" + q.Add("pageSize", strconv.Itoa(queryArgs[0].PageSize)) } if queryArgs[0].Search != "" { - getURL += fmt.Sprintf("search=%s", queryArgs[0].Search) - getURL += "&" + q.Add("search", queryArgs[0].Search) } - getURL := fmt.Sprintf("showAll=%t", queryArgs[0].ShowAll) - getURL += "&" + q.Add("showAll", strconv.FormatBool(queryArgs[0].ShowAll)) if queryArgs[0].SortBy != "" { - getURL += fmt.Sprintf("sortBy=%s", queryArgs[0].SortBy) - getURL += "&" + q.Add("sortBy", queryArgs[0].SortBy) } if queryArgs[0].Types != "" { - getURL += fmt.Sprintf("types=%s", queryArgs[0].Types) - getURL += "&" + q.Add("types", queryArgs[0].Types) } - getURL = strings.TrimRight(getURL, "&") - getURL = strings.TrimRight(getURL, "?") - } - - req, err := client.NewRequest( - Config, - "GET", - getURL, - nil, - ) - if err != nil { - return nil, err + req.URL.RawQuery = q.Encode() } edge.PrintHttpRequest(req, true)