| 225 | } |
| 226 | |
| 227 | func (b *Builder) BuildRequest(ctx context.Context, body interface{}) (*retryablehttp.Request, error) { |
| 228 | b.r.Header = b.Config.header |
| 229 | b.Config.auth.apply(b.r) |
| 230 | |
| 231 | // According to the HTTP spec any request method, but TRACE is allowed to |
| 232 | // have a body. Even this is a bad practice for some of them, like for GET |
| 233 | if b.Config.Method != http.MethodTrace { |
| 234 | if err := b.addBody(ctx, body); err != nil { |
| 235 | return nil, err |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | return b.r, nil |
| 240 | } |
| 241 | |
| 242 | func (b *Builder) addRawBody(body any) (err error) { |
| 243 | if isNilInterface(body) { |