ee78c76085
We need still to add similar wrappers to internal/netxlite but we will adopt a saner approach to error wrapping this time. See https://github.com/ooni/probe/issues/1591
28 lines
821 B
Go
28 lines
821 B
Go
package websteps
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
|
|
errorsxlegacy "github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
|
"github.com/ooni/probe-cli/v3/internal/engine/model"
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite/errorsx"
|
|
)
|
|
|
|
// Control performs the control request and returns the response.
|
|
func Control(
|
|
ctx context.Context, sess model.ExperimentSession,
|
|
thAddr string, resourcePath string, creq CtrlRequest) (out CtrlResponse, err error) {
|
|
clnt := httpx.Client{
|
|
BaseURL: thAddr,
|
|
HTTPClient: sess.DefaultHTTPClient(),
|
|
Logger: sess.Logger(),
|
|
}
|
|
// make sure error is wrapped
|
|
err = errorsxlegacy.SafeErrWrapperBuilder{
|
|
Error: clnt.PostJSON(ctx, resourcePath, creq, &out),
|
|
Operation: errorsx.TopLevelOperation,
|
|
}.MaybeBuild()
|
|
return
|
|
}
|