request

package
v1.4.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
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 BodyOp added in v1.4.3

type BodyOp struct {
	Type          BodyType
	Bytes         []byte
	Reader        io.ReadCloser
	JSON          any
	ContentType   string
	ContentLength int64
}

type BodyType added in v1.4.3

type BodyType uint8
const (
	BodyTypeNone BodyType = iota
	BodyTypeBytes
	BodyTypeReader
	BodyTypeJSON
)

type FileOp added in v1.4.3

type FileOp struct {
	Key      string
	Filename string
	Content  io.Reader
}

type ItemOp added in v1.4.4

type ItemOp struct {
	Key, Value string
}

type Multipart

type Multipart struct {
	// contains filtered or unexported fields
}

Multipart represents a multipart/form-data request builder.

func NewMultipart

func NewMultipart(ctx context.Context, c *http.Client, method, url string) *Multipart

NewMultipart creates a new multipart/form-data request builder.

func NewMultipartWithOpsCapacity added in v1.4.1

func NewMultipartWithOpsCapacity(ctx context.Context, c *http.Client, method, url string, opsCapacity int) *Multipart

func (*Multipart) Bool

func (r *Multipart) Bool(fieldName string, value bool) *Multipart

func (*Multipart) File

func (r *Multipart) File(key, filename string, content io.Reader) *Multipart

func (*Multipart) FileCount added in v1.4.3

func (r *Multipart) FileCount() int

func (*Multipart) Float

func (r *Multipart) Float(fieldName string, value float64) *Multipart

func (*Multipart) Header

func (r *Multipart) Header(key, value string) *Multipart

func (*Multipart) Param

func (r *Multipart) Param(key, value string) *Multipart

func (*Multipart) ParamCount added in v1.4.3

func (r *Multipart) ParamCount() int

func (*Multipart) Send

func (r *Multipart) Send() (*http.Response, error)

Send executes all operations and sends the multipart request.

func (*Multipart) TotalOps added in v1.4.3

func (r *Multipart) TotalOps() int

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request represents an HTTP request builder with minimal allocations.

func NewRequest

func NewRequest(ctx context.Context, c *http.Client, method, url string) *Request

NewRequest creates a new HTTP request builder.

func NewRequestWithOpsCapacity added in v1.4.1

func NewRequestWithOpsCapacity(ctx context.Context, c *http.Client, method, urlStr string, opsCapacity int) *Request

func (*Request) Body

func (r *Request) Body(body io.ReadCloser, contentType string, contentLength int64) *Request

func (*Request) Bool

func (r *Request) Bool(fieldName string, value bool) *Request

func (*Request) Bytes

func (r *Request) Bytes(body []byte, contentType string) *Request

func (*Request) Float

func (r *Request) Float(fieldName string, value float64) *Request

func (*Request) HasBody added in v1.4.3

func (r *Request) HasBody() bool

func (*Request) Header

func (r *Request) Header(key, value string) *Request

func (*Request) HeaderCount added in v1.4.3

func (r *Request) HeaderCount() int

func (*Request) JSON

func (r *Request) JSON(body any) *Request

func (*Request) Param

func (r *Request) Param(key, value string) *Request

func (*Request) ParamCount added in v1.4.3

func (r *Request) ParamCount() int

func (*Request) Send

func (r *Request) Send() (*http.Response, error)

Send executes all operations and sends the HTTP request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL