From b7683ab8dcdeca10ff52d626a285edcf7c1db719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Mon, 1 Jul 2024 16:12:52 +0200 Subject: Remove context from struct, add ctx as first args to many functions --- account.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'account.go') diff --git a/account.go b/account.go index cdccc78..3b37b17 100644 --- a/account.go +++ b/account.go @@ -98,7 +98,7 @@ func (a *Account) Backend() Backend { // // WARNING: This method is not thread-safe. Calling it concurrently on the same // object results in undefined behavior. -func (a *Account) Headers() (AccountHeaders, error) { +func (a *Account) Headers(ctx context.Context) (AccountHeaders, error) { if a.headers != nil { return *a.headers, nil } @@ -106,7 +106,7 @@ func (a *Account) Headers() (AccountHeaders, error) { resp, err := Request{ Method: "HEAD", ExpectStatusCodes: []int{204}, - }.Do(a.backend) + }.Do(ctx, a.backend) if err != nil { return AccountHeaders{}, err } @@ -134,12 +134,12 @@ func (a *Account) Invalidate() { // attribute take precedence over those in opts.Headers. // // A successful POST request implies Invalidate() since it may change metadata. -func (a *Account) Update(headers AccountHeaders, opts *RequestOptions) error { +func (a *Account) Update(ctx context.Context, headers AccountHeaders, opts *RequestOptions) error { resp, err := Request{ Method: "POST", Options: cloneRequestOptions(opts, headers.Headers), ExpectStatusCodes: []int{204}, - }.Do(a.backend) + }.Do(ctx, a.backend) if err == nil { a.Invalidate() resp.Body.Close() @@ -151,13 +151,13 @@ func (a *Account) Update(headers AccountHeaders, opts *RequestOptions) error { // available to reseller admins, not to regular users. // // A successful PUT request implies Invalidate() since it may change metadata. -func (a *Account) Create(opts *RequestOptions) error { +func (a *Account) Create(ctx context.Context, opts *RequestOptions) error { resp, err := Request{ Method: "PUT", Options: opts, ExpectStatusCodes: []int{201, 202}, DrainResponseBody: true, - }.Do(a.backend) + }.Do(ctx, a.backend) if err == nil { a.Invalidate() resp.Body.Close() -- cgit v1.2.3