request

package
v1.9.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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, transport func() http.RoundTripper) *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) Cookie added in v1.9.3

func (r *Request) Cookie(name, value string) *Request

Cookie adds a cookie to the request. Subsequent calls append additional cookies.

func (*Request) Float

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

Float adds a float64 query parameter to the request.

func (*Request) Form added in v1.8.1

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

Form sets the request body as form data.

func (*Request) Header

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

Header sets an HTTP header on the request.

func (*Request) Int

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(body 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) PathBool

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

PathBool replaces a path variable placeholder with a boolean value.

func (*Request) PathFloat

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

PathFloat replaces a path variable placeholder with a float64 value.

func (*Request) PathInt

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

PathInt replaces a path variable placeholder with an integer value.

func (*Request) PathParam

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

PathParam replaces a path variable placeholder in the URL. Replaces {key} with the provided value. Example: "/users/{id}" with PathParam("id", "123") becomes "/users/123"

func (*Request) Send

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

Send executes the HTTP request and returns the response.

func (*Request) Timeout

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