Prevent sending empty body in OTC DNS Provider (#903)

This commit is contained in:
Felix Meißner 2019-06-14 14:19:38 +02:00 committed by Ludovic Fernandez
parent 99741b0b92
commit 346d3222d7

View file

@ -230,12 +230,16 @@ func (d *DNSProvider) deleteRecordSet(zoneID, recordID string) error {
func (d *DNSProvider) sendRequest(method, resource string, payload interface{}) (io.Reader, error) {
url := fmt.Sprintf("%s/%s", d.baseURL, resource)
body, err := json.Marshal(payload)
if err != nil {
return nil, err
var body io.Reader
if payload != nil {
content, err := json.Marshal(payload)
if err != nil {
return nil, err
}
body = bytes.NewReader(content)
}
req, err := http.NewRequest(method, url, bytes.NewReader(body))
req, err := http.NewRequest(method, url, body)
if err != nil {
return nil, err
}