@@ -35,6 +35,7 @@ import (
35
35
"net/http/httputil"
36
36
"time"
37
37
38
+ "github.com/goccy/go-yaml"
38
39
"gopkg.in/dnaeon/go-vcr.v4/pkg/cassette"
39
40
)
40
41
@@ -209,6 +210,8 @@ type Recorder struct {
209
210
210
211
// fs specifies custom filesystem ([cassette.FS]) implementation.
211
212
fs cassette.FS
213
+
214
+ encodeOptions []yaml.EncodeOption
212
215
}
213
216
214
217
// Option is a function which configures the [Recorder].
@@ -313,6 +316,15 @@ func WithFS(fs cassette.FS) Option {
313
316
return opt
314
317
}
315
318
319
+ // WithEncodeOptions is an [Option], which configures the [Recorder] to use
320
+ // custom YAML encoder options. This allows customization of the YAML encoding
321
+ // process, such as setting string literal style, etc.
322
+ func WithEncodeOptions (encodeOptions ... yaml.EncodeOption ) Option {
323
+ return func (r * Recorder ) {
324
+ r .encodeOptions = encodeOptions
325
+ }
326
+ }
327
+
316
328
// New creates a new [Recorder] and configures it using the provided options.
317
329
func New (cassetteName string , opts ... Option ) (* Recorder , error ) {
318
330
r := & Recorder {
@@ -340,6 +352,7 @@ func New(cassetteName string, opts ...Option) (*Recorder, error) {
340
352
r .cassette = c
341
353
r .cassette .Matcher = r .matcher
342
354
r .cassette .ReplayableInteractions = r .replayableInteractions
355
+ r .cassette .EncodeOptions = r .encodeOptions
343
356
344
357
return r , nil
345
358
}
0 commit comments