28ce79eff1
* feat(ooapi): add toplevel client and simplify API This diff should simplify using ooapi from other packages by adding more abstraction that wraps the existing code. Part of https://github.com/ooni/probe/issues/1355. * fix(ooapi): use correct comment for cloners See https://github.com/ooni/probe-cli/pull/248#discussion_r590663843 * fix(ooapi): make sure the documentation is current See https://github.com/ooni/probe-cli/pull/248#discussion_r590665773 * fix(ooapi): automate copying APIs See https://github.com/ooni/probe-cli/pull/248#discussion_r590665837 * feat(ooapi): add unit tests for clientcall.go See https://github.com/ooni/probe-cli/pull/248#discussion_r590666297 * fix(ooapi): rewrite integration tests to use toplevel API See https://github.com/ooni/probe-cli/pull/248#discussion_r590665084
22 lines
392 B
Go
22 lines
392 B
Go
package ooapi
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
)
|
|
|
|
type VerboseHTTPClient struct {
|
|
T *testing.T
|
|
}
|
|
|
|
func (c *VerboseHTTPClient) Do(req *http.Request) (*http.Response, error) {
|
|
c.T.Logf("> %s %s", req.Method, req.URL.String())
|
|
resp, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
c.T.Logf("< %s", err.Error())
|
|
return nil, err
|
|
}
|
|
c.T.Logf("< %d", resp.StatusCode)
|
|
return resp, nil
|
|
}
|