httputil

package
v0.0.47-alpha.39 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

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 (*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