Skip to content

Commit

Permalink
Add Context usage to HTTPDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiante committed Sep 24, 2023
1 parent fea63a4 commit ca5ce6a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/driver/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package driver

import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -44,7 +45,7 @@ func (driver *HTTPDriver) newRequest(method, url string, body io.Reader) (*http.
return req, nil
}

func (driver *HTTPDriver) ResolvePURL(domain string, name string) (*url.URL, error) {
func (driver *HTTPDriver) ResolvePURL(ctx context.Context, domain string, name string) (*url.URL, error) {
req, err := driver.newRequest(http.MethodGet, fmt.Sprintf("%s/r/%s/%s", driver.BasePath, domain, name), nil)
if err != nil {
return nil, err
Expand Down Expand Up @@ -72,7 +73,7 @@ func (driver *HTTPDriver) ResolvePURL(domain string, name string) (*url.URL, err
return loc, nil
}

func (driver *HTTPDriver) SavePURL(purl *dsl.PURL) (string, error) {
func (driver *HTTPDriver) SavePURL(ctx context.Context, purl *dsl.PURL) (string, error) {
body := bytes.NewBuffer([]byte{})
err := json.NewEncoder(body).Encode(map[string]string{
"target": purl.Target.String(),
Expand Down Expand Up @@ -107,7 +108,7 @@ func (driver *HTTPDriver) SavePURL(purl *dsl.PURL) (string, error) {
return r.Path, nil
}

func (driver *HTTPDriver) CreateDomain(name string) error {
func (driver *HTTPDriver) CreateDomain(ctx context.Context, name string) error {
req, err := driver.newRequest(http.MethodPost, fmt.Sprintf("%s/a/domains/%s", driver.BasePath, name), nil)
if err != nil {
return err
Expand Down

0 comments on commit ca5ce6a

Please sign in to comment.