f0181c432f
This concludes the TODO list at https://github.com/ooni/probe/issues/1951
28 lines
838 B
Go
28 lines
838 B
Go
package websteps
|
|
|
|
import (
|
|
"context"
|
|
|
|
errorsxlegacy "github.com/ooni/probe-cli/v3/internal/engine/legacy/errorsx"
|
|
"github.com/ooni/probe-cli/v3/internal/httpx"
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
|
)
|
|
|
|
// 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.APIClientTemplate{
|
|
BaseURL: thAddr,
|
|
HTTPClient: sess.DefaultHTTPClient(),
|
|
Logger: sess.Logger(),
|
|
}
|
|
// make sure error is wrapped
|
|
err = errorsxlegacy.SafeErrWrapperBuilder{
|
|
Error: clnt.WithBodyLogging().Build().PostJSON(ctx, resourcePath, creq, &out),
|
|
Operation: netxlite.TopLevelOperation,
|
|
}.MaybeBuild()
|
|
return
|
|
}
|