Documentation
¶
Overview ¶
Package bodyprovider implements the concrete BodyProvider variants used by the greq client (reader, JSON, form, multipart). The greq.BodyProvider interface is structurally satisfied by every type in this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Form ¶
type Form struct {
// contains filtered or unexported fields
}
Form encodes a url tagged struct value (or string/url.Values/map[string][]string) as form body.
func (Form) ContentType ¶
ContentType returns application/x-www-form-urlencoded.
type JSON ¶
type JSON struct {
// contains filtered or unexported fields
}
JSON encodes a JSON tagged struct value as request body.
type Multipart ¶
type Multipart struct {
// contains filtered or unexported fields
}
Multipart builds a multipart/form-data body from files and fields. Uses a pointer receiver because Body() lazily materializes the buffer.
IMPORTANT: ContentType() returns "" until Body() has been called at least once (because the multipart boundary is generated during build()). Callers that need both the body and the Content-Type header MUST call Body() first. The greq client does this already in NewRequestWithOptions.
func NewMultipart ¶
NewMultipart returns a Multipart provider. Either map may be nil.
func (*Multipart) ContentType ¶
ContentType returns the multipart Content-Type including the boundary. Returns empty string until Body() has been called at least once.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader wraps an io.Reader and exposes it as a body without a Content-Type.
func (Reader) ContentType ¶
ContentType returns the Content-Type — empty for raw reader bodies.