mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-21 01:26:48 +00:00
GODT-35: New pmapi client and manager using resty
This commit is contained in:
@ -21,6 +21,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/nsf/jsondiff"
|
||||
)
|
||||
|
||||
@ -39,23 +40,31 @@ type fakeCall struct {
|
||||
request []byte
|
||||
}
|
||||
|
||||
func (ctl *Controller) recordCall(method method, path string, req interface{}) {
|
||||
func (ctl *Controller) recordCall(method method, path string, req interface{}) error {
|
||||
ctl.lock.Lock()
|
||||
defer ctl.lock.Unlock()
|
||||
|
||||
request := []byte{}
|
||||
var request []byte
|
||||
|
||||
if req != nil {
|
||||
var err error
|
||||
request, err = json.Marshal(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
if request, err = json.Marshal(req); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
ctl.calls = append(ctl.calls, &fakeCall{
|
||||
method: method,
|
||||
path: path,
|
||||
request: request,
|
||||
})
|
||||
|
||||
if ctl.noInternetConnection {
|
||||
return pmapi.ErrNoConnection
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ctl *Controller) PrintCalls() {
|
||||
|
||||
Reference in New Issue
Block a user