httputil

package
v0.0.50-alpha.111 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	Timeout         time.Duration
	MaxConnsPerHost int
}

ClientConfig defines configuration for the HTTP client.

func NewClientConfig

func NewClientConfig() *ClientConfig

NewClientConfig creates a default client configuration.

type HTTPClient

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

HTTPClient wraps http.Client and includes additional configuration.

func NewHTTPClient

func NewHTTPClient(config *ClientConfig) *HTTPClient

NewHTTPClient creates a new HTTPClient with the provided configuration.

func NewHTTPClientWithClient

func NewHTTPClientWithClient(client *http.Client, config *ClientConfig) *HTTPClient

NewHTTPClientWithClient creates a new HTTPSClient with the provided configuration and http.Client.

func (*HTTPClient) Get

func (c *HTTPClient) Get(url string) ([]byte, error)

Get performs a HTTP GET request and returns the response body.

func (*HTTPClient) Post

func (c *HTTPClient) Post(ctx context.Context, url string, headers map[string]string, data any, timeout int) ([]byte, error)

Post sends a JSON-encoded POST request and returns the response body.

func (*HTTPClient) PostReturn

func (c *HTTPClient) PostReturn(ctx context.Context, url string, headers map[string]string, input, output any, timeout int) error

PostReturn sends a JSON-encoded POST request and decodes the JSON response into output parameter.

Jump to

Keyboard shortcuts

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