From 5791a4c9ae5791d51d8b538fdd18e4096fd9b311 Mon Sep 17 00:00:00 2001 From: "Plushnikov, Michail" Date: Fri, 18 Aug 2023 08:46:50 +0200 Subject: [PATCH] feat(RELTEC-11329): support playback for []byte responces --- implementation/playback/playback.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/implementation/playback/playback.go b/implementation/playback/playback.go index 8d9d364..88f6a81 100644 --- a/implementation/playback/playback.go +++ b/implementation/playback/playback.go @@ -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" @@ -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