Documentation
¶
Index ¶
- Constants
- type Multipart
- func (r *Multipart) Bool(fieldName string, value bool) *Multipart
- func (r *Multipart) File(key, filename string, content io.Reader) *Multipart
- func (r *Multipart) Float(fieldName string, value float64) *Multipart
- func (r *Multipart) Header(key, value string) *Multipart
- func (r *Multipart) Param(key, value string) *Multipart
- func (r *Multipart) Send() (*http.Response, error)
- type Request
- func (r *Request) Body(body io.ReadCloser) *Request
- func (r *Request) Bool(fieldName string, value bool) *Request
- func (r *Request) Bytes(body []byte) *Request
- func (r *Request) Float(fieldName string, value float64) *Request
- func (r *Request) Header(key, value string) *Request
- func (r *Request) JSON(body any) *Request
- func (r *Request) Param(key, value string) *Request
- func (r *Request) Send() (*http.Response, error)
Constants ¶
const ( ApplicationJSON = "application/json" ContentType = "Content-Type" ContentLength = "Content-Length" )
HTTP header constants used throughout the request package.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Multipart ¶
type Multipart struct {
// contains filtered or unexported fields
}
Multipart represents a multipart/form-data request builder. It uses streaming with io.Pipe to avoid buffering the entire request in memory.
func NewMultipart ¶
NewMultipart creates a new multipart/form-data request builder. If the request creation fails, the error will be returned when Send is called.
func (*Multipart) File ¶
File adds a file field to the multipart request. The content will be read when Send is called.
func (*Multipart) Header ¶
Header adds a header to the request. This is applied immediately, not deferred.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request represents an HTTP request builder that uses deferred operations. All configuration methods are applied only when Send is called.
func NewRequest ¶
NewRequest creates a new HTTP request builder. If the request creation fails, the error will be returned when Send is called.
func (*Request) Body ¶
func (r *Request) Body(body io.ReadCloser) *Request
Body sets the request body. Any existing body will be closed when Send is called.
func (*Request) Bytes ¶
Bytes sets the request body from a byte slice and sets the Content-Length header.
func (*Request) Header ¶
Header adds a header to the request. The header is set when Send is called.
func (*Request) JSON ¶
JSON marshals the provided value to JSON and sets it as the request body. Also sets the Content-Type header to application/json.