func Callback(cbReq *CallbackRequest, opts *CallbackOptions) error {
	client := opts.Client
	if client == nil {
		client = http.DefaultClient
	}
	buf := bytes.NewBuffer(nil)
	err := json.NewEncoder(buf).Encode(cbReq)
	if err != nil {
		return err
	}
	signature, err := opts.Signer.Sign(buf.Bytes())
	if err != nil {
		return err
	}
	req, err := http.NewRequest("POST", cbReq.StatusCallbackUrl, buf)
	if err != nil {
		return err
	}
	req.Header.Set("X-OpenGDPR-Processor-Domain", opts.ProcessorDomain)
	req.Header.Set("X-OpenGDPR-Signature", signature)
	// Attempt to make callback
	for i := 0; i < opts.MaxAttempts; i++ {
		resp, err := client.Do(req)
		if err != nil || resp.StatusCode != 200 {
			time.Sleep(opts.Backoff)
			continue
		}
		// Success
		return nil
	}
	return fmt.Errorf("callback timed out for %s", cbReq.StatusCallbackUrl)
}
func Callback(cbReq *CallbackRequest, opts *CallbackOptions) error {
	client := opts.Client
	if client == nil {
		client = http.DefaultClient
	}
	buf := bytes.NewBuffer(nil)
	err := json.NewEncoder(buf).Encode(cbReq)
	if err != nil {
		return err
	}
	signature, err := opts.Signer.Sign(buf.Bytes())
	if err != nil {
		return err
	}
	req, err := http.NewRequest("POST", cbReq.StatusCallbackUrl, buf)
	if err != nil {
		return err
	}
	req.Header.Set("X-OpenGDPR-Processor-Domain", opts.ProcessorDomain)
	req.Header.Set("X-OpenGDPR-Signature", signature)
	
	for i := 0; i < opts.MaxAttempts; i++ {
		resp, err := client.Do(req)
		if err != nil || resp.StatusCode != 200 {
			time.Sleep(opts.Backoff)
			continue
		}
		
		return nil
	}
	return fmt.Errorf("callback timed out for %s", cbReq.StatusCallbackUrl)
}
func Callback ( cbReq * CallbackRequest , opts * CallbackOptions ) error { client := opts . Client if client == nil { client = http . DefaultClient } buf := bytes . NewBuffer ( nil ) err := json . NewEncoder ( buf ) . Encode ( cbReq ) if err != nil { return err } signature , err := opts . Signer . Sign ( buf . Bytes ( ) ) if err != nil { return err } req , err := http . NewRequest ( " " , cbReq . StatusCallbackUrl , buf ) if err != nil { return err } req . Header . Set ( " " , opts . ProcessorDomain ) req . Header . Set ( " " , signature ) // Attempt to make callback for i := 0 ; i < opts . MaxAttempts ; i ++ { resp , err := client . Do ( req ) if err != nil || resp . StatusCode != 200 { time . Sleep ( opts . Backoff ) continue } // Success return nil } return fmt . Errorf ( " " , cbReq . StatusCallbackUrl ) }
// Callback sends the CallbackRequest type to the configured
// StatusCallbackUrl. If it fails to deliver in n attempts or
// the request is invalid it will return an error.
Callback sends the CallbackRequest type to the configured StatusCallbackUrl . If it fails to deliver in n attempts or the request is invalid it will return an error .