Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(RELTEC-11329): support playback for []byte responces #24

Merged
merged 1 commit into from Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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