Skip to content

Commit

Permalink
rest: add optional GetBody function for HTTP call
Browse files Browse the repository at this point in the history
  • Loading branch information
devnoname120 authored and ncw committed Mar 17, 2023
1 parent 82f9554 commit 4af0c1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ type Opts struct {
Path string // relative to RootURL
RootURL string // override RootURL passed into SetRoot()
Body io.Reader
NoResponse bool // set to close Body
GetBody func() (io.ReadCloser, error) // body builder, needed to enable low-level HTTP/2 retries
NoResponse bool // set to close Body
ContentType string
ContentLength *int64
ContentRange string
Expand Down Expand Up @@ -239,6 +240,9 @@ func (api *Client) Call(ctx context.Context, opts *Opts) (resp *http.Response, e
if len(opts.TransferEncoding) != 0 {
req.TransferEncoding = opts.TransferEncoding
}
if opts.GetBody != nil {
req.GetBody = opts.GetBody
}
if opts.Trailer != nil {
req.Trailer = *opts.Trailer
}
Expand Down

0 comments on commit 4af0c1d

Please sign in to comment.