Skip to content

Commit

Permalink
correct GetRecordsets qarg processing
Browse files Browse the repository at this point in the history
  • Loading branch information
edglynes committed Apr 3, 2020
1 parent 8e5cc3a commit cc2ac05
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions configdns-v2/record_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cc2ac05

Please sign in to comment.