This is still quite easy to stub, and the extra information is very useful to the caller. Signed-off-by: Yonah <contrib@gensokyo.uk>
21 lines
395 B
Go
21 lines
395 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
type netDirect struct {
|
|
c http.Client
|
|
}
|
|
|
|
func (n *netDirect) Get(ctx context.Context, url string) (*http.Response, error) {
|
|
var resp *http.Response
|
|
if req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil); err != nil {
|
|
return nil, err
|
|
} else if resp, err = n.c.Do(req); err != nil {
|
|
return nil, err
|
|
}
|
|
return resp, nil
|
|
}
|