request

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApplicationJSON = "application/json"
	ContentType     = "Content-Type"
)

HTTP header constants used throughout the request package.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataType added in v1.4.9

type DataType int
const (
	NoneType DataType = iota
	ParamType
	FileType
	JSONType
)

type Multipart

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

Multipart provides a streaming multipart/form-data builder for HTTP requests.

func NewMultipart

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

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

func (*Multipart) Bool

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

Bool adds a boolean field to the multipart form.

func (*Multipart) File

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

File adds a file field to the multipart form.

func (*Multipart) Float

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

Float adds a float64 field to the multipart form.

func (*Multipart) Header

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

Header sets an HTTP header on the request.

func (*Multipart) Int added in v1.4.9

func (r *Multipart) Int(key string, value int) *Multipart

Int adds an integer field to the multipart form.

func (*Multipart) Param

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

Param adds a string field to the multipart form.

func (*Multipart) Send

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

Send executes the HTTP request and returns the response.

func (*Multipart) Timeout added in v1.6.0

func (r *Multipart) Timeout(duration time.Duration) *Multipart

Timeout sets a timeout for the request.

type Request

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

Request provides a builder for standard HTTP requests.

func NewRequest

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

NewRequest creates a new HTTP request builder.

func (*Request) Body

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

Body sets the request body and Content-Type header.

func (*Request) Bool

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

Bool adds a boolean query parameter to the request.

func (*Request) Float

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

Float adds a float64 query parameter to the request.

func (*Request) Header

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

Header sets an HTTP header on the request.

func (*Request) Int added in v1.4.9

func (r *Request) Int(key string, value int) *Request

Int adds an integer query parameter to the request.

func (*Request) JSON

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

JSON sets the request body as JSON.

func (*Request) Param

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

Param adds a query parameter to the request.

func (*Request) Send

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

Send executes the HTTP request and returns the response.

func (*Request) Timeout added in v1.6.0

func (r *Request) Timeout(duration time.Duration) *Request

Timeout sets a timeout for the request.

Jump to

Keyboard shortcuts

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