Skip to content

Commit f2e2e2e

Browse files
chore(docs): document pre-request options
1 parent df86410 commit f2e2e2e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

internal/requestconfig/requestconfig.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -589,16 +589,20 @@ func (cfg *RequestConfig) Apply(opts ...RequestOption) error {
589589
return nil
590590
}
591591

592+
// PreRequestOptions is used to collect all the options which need to be known before
593+
// a call to [RequestConfig.ExecuteNewRequest], such as path parameters
594+
// or global defaults.
595+
// PreRequestOptions will return a [RequestConfig] with the options applied.
596+
//
597+
// Only request option functions of type [PreRequestOptionFunc] are applied.
592598
func PreRequestOptions(opts ...RequestOption) (RequestConfig, error) {
593599
cfg := RequestConfig{}
594600
for _, opt := range opts {
595-
if _, ok := opt.(PreRequestOptionFunc); !ok {
596-
continue
597-
}
598-
599-
err := opt.Apply(&cfg)
600-
if err != nil {
601-
return cfg, err
601+
if opt, ok := opt.(PreRequestOptionFunc); ok {
602+
err := opt.Apply(&cfg)
603+
if err != nil {
604+
return cfg, err
605+
}
602606
}
603607
}
604608
return cfg, nil

0 commit comments

Comments
 (0)