diff --git a/internal/unifi/provider.go b/internal/unifi/provider.go index 729514e..33b1b65 100644 --- a/internal/unifi/provider.go +++ b/internal/unifi/provider.go @@ -17,7 +17,7 @@ type Provider struct { domainFilter endpoint.DomainFilter } -// newUnifiProvider initializes a new DNSProvider. +// NewUnifiProvider initializes a new DNSProvider. func NewUnifiProvider(domainFilter endpoint.DomainFilter, config *Config) (provider.Provider, error) { c, err := newUnifiClient(config) @@ -77,6 +77,6 @@ func (p *Provider) ApplyChanges(ctx context.Context, changes *plan.Changes) erro } // GetDomainFilter returns the domain filter for the provider. -func (p *Provider) GetDomainFilter() endpoint.DomainFilter { +func (p *Provider) GetDomainFilter() endpoint.DomainFilterInterface { return p.domainFilter } diff --git a/pkg/webhook/webhook.go b/pkg/webhook/webhook.go index 735ad4d..28d9c34 100644 --- a/pkg/webhook/webhook.go +++ b/pkg/webhook/webhook.go @@ -200,19 +200,13 @@ func (p *Webhook) Negotiate(w http.ResponseWriter, r *http.Request) { return } - b, err := p.provider.GetDomainFilter().MarshalJSON() + w.Header().Set(contentTypeHeader, string(mediaTypeVersion1)) + err := json.NewEncoder(w).Encode(p.provider.GetDomainFilter()) if err != nil { requestLog(r).Error("failed to marshal domain filter") w.WriteHeader(http.StatusInternalServerError) return } - - w.Header().Set(contentTypeHeader, string(mediaTypeVersion1)) - if _, writeError := w.Write(b); writeError != nil { - requestLog(r).With(zap.Error(writeError)).Error("error writing response") - w.WriteHeader(http.StatusInternalServerError) - return - } } func requestLog(r *http.Request) *zap.Logger {