Skip to content

Commit

Permalink
Replace hard coded per_page parameter on DNS API with default
Browse files Browse the repository at this point in the history
The API has increased its limit to 5000 therefore its easier for both client
and server to grab as many records as possible per query. This may change in the future
and therefore we should just use default.

https://api.cloudflare.com/#dns-records-for-a-zone-list-dns-records
  • Loading branch information
Fattouche committed Jan 10, 2022
1 parent 546e02e commit 51d9037
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
3 changes: 1 addition & 2 deletions dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ func (api *API) CreateDNSRecord(ctx context.Context, zoneID string, rr DNSRecord
func (api *API) DNSRecords(ctx context.Context, zoneID string, rr DNSRecord) ([]DNSRecord, error) {
// Construct a query string
v := url.Values{}
// Request as many records as possible per page - API max is 100
v.Set("per_page", "100")
// Using default per_page value as specified by the API
if rr.Name != "" {
v.Set("name", toUTS46ASCII(rr.Name))
}
Expand Down
1 change: 0 additions & 1 deletion dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ func TestDNSRecords(t *testing.T) {

handler := func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
assert.Equal(t, "100", r.URL.Query().Get("per_page"))
assert.Equal(t, asciiInput.Name, r.URL.Query().Get("name"))
assert.Equal(t, asciiInput.Type, r.URL.Query().Get("type"))
assert.Equal(t, asciiInput.Content, r.URL.Query().Get("content"))
Expand Down

0 comments on commit 51d9037

Please sign in to comment.