Skip to content

Commit

Permalink
Merge pull request #24 from mpl-interhyp/main
Browse files Browse the repository at this point in the history
feat(RELTEC-11329): support playback for []byte responces
  • Loading branch information
StephanHCB committed Aug 18, 2023
2 parents cc43337 + 5791a4c commit 1cf4096
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions implementation/playback/playback.go
Expand Up @@ -3,12 +3,13 @@ package aurestplayback
import (
"context"
"encoding/json"
aulogging "github.com/StephanHCB/go-autumn-logging"
aurestclientapi "github.com/StephanHCB/go-autumn-restclient/api"
aurestrecorder "github.com/StephanHCB/go-autumn-restclient/implementation/recorder"
"os"
"path/filepath"
"time"

aulogging "github.com/StephanHCB/go-autumn-logging"
aurestclientapi "github.com/StephanHCB/go-autumn-restclient/api"
aurestrecorder "github.com/StephanHCB/go-autumn-restclient/implementation/recorder"
)

const PlaybackRewritePathEnvVariable = "GO_AUTUMN_RESTCLIENT_PLAYBACK_REWRITE_PATH"
Expand Down Expand Up @@ -97,9 +98,15 @@ func (c *PlaybackImpl) Perform(ctx context.Context, method string, requestUrl st
if err != nil {
return err
}
err = json.Unmarshal(bodyJsonBytes, response.Body)
if err != nil {
return err

switch response.Body.(type) {
case **[]byte:
*(response.Body.(**[]byte)) = &bodyJsonBytes
default:
err = json.Unmarshal(bodyJsonBytes, response.Body)
if err != nil {
return err
}
}

return recording.Error
Expand Down

0 comments on commit 1cf4096

Please sign in to comment.