client

package
v0.0.0-...-5a55354 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilContext        = errors.New("context cannot be nil")
	ErrEmptyURL          = errors.New("URL cannot be empty")
	ErrInvalidResponse   = errors.New("invalid response")
	ErrRequestFailed     = errors.New("request failed")
	ErrInvalidTimeout    = errors.New("timeout cannot be negative")
	ErrInvalidRetryCount = errors.New("retry count cannot be negative")
	ErrInvalidRetryWait  = errors.New("retry wait cannot be negative")
)

Common errors

Functions

This section is empty.

Types

type Init

type Init struct {
	Params     map[string]string
	Query      map[string]string
	Headers    map[string]string
	FormData   map[string]string
	Files      map[string]string
	Body       interface{}
	Timeout    time.Duration
	RetryCount int
	RetryWait  time.Duration
	BaseURL    string
}

type Response

type Response[T any] struct {
	StatusCode int
	Headers    http.Header
	Resty      *resty.Response
	Body       T
}

func DeleteJSON

func DeleteJSON[R any](ctx context.Context, url string, init Init) (Response[*R], error)

func GetBytes

func GetBytes(ctx context.Context, url string, init Init) (Response[[]byte], error)

func GetJSON

func GetJSON[R any](ctx context.Context, url string, init Init) (Response[*R], error)

func PatchJSON

func PatchJSON[R any](ctx context.Context, url string, init Init) (Response[*R], error)

func PostBytes

func PostBytes(ctx context.Context, url string, init Init) (Response[[]byte], error)

func PostJSON

func PostJSON[R any](ctx context.Context, url string, init Init) (Response[*R], error)

func PutJSON

func PutJSON[R any](ctx context.Context, url string, init Init) (Response[*R], error)

Jump to

Keyboard shortcuts

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