httpclient

package
v0.0.0-...-7a46742 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidBody   = errors.New("failed to marshal request body")
	ErrCreateRequest = errors.New("failed to create request")
	ErrDoRequest     = errors.New("failed to do request")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	// Get sends an HTTP GET request to the specified URL with optional headers.
	Get(ctx context.Context, url string, headers ReqHeader) (*http.Response, error)

	// Post sends an HTTP POST request with a JSON-serializable body and optional headers.
	Post(ctx context.Context, url string, reqBody any, headers ReqHeader) (*http.Response, error)

	// Put sends an HTTP PUT request with a JSON-serializable body and optional headers.
	Put(ctx context.Context, url string, reqBody any, headers ReqHeader) (*http.Response, error)

	// Put sends an HTTP PUT request with a JSON-serializable body and optional headers.
	Patch(ctx context.Context, url string, reqBody any, headers ReqHeader) (*http.Response, error)

	// Delete sends an HTTP DELETE request to the specified URL with optional JSON body and headers.
	Delete(ctx context.Context, url string, reqBody any, headers ReqHeader) (*http.Response, error)
}

Client defines a simple HTTP client interface for making RESTful requests with optional headers and JSON payloads.

func New

func New() Client

type ReqHeader

type ReqHeader = map[string]string

Jump to

Keyboard shortcuts

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