httputil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2023 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPClient

type HTTPClient struct {
	Client    *http.Client
	BaseURL   string
	Timeout   time.Duration
	UserAgent string
}

HTTPClient is a struct for configuring the HTTP client.

func NewHTTPClient

func NewHTTPClient(baseURL string, timeout time.Duration, userAgent string) *HTTPClient

NewHTTPClient creates a new HTTPClient with default configurations.

func (*HTTPClient) Request

func (c *HTTPClient) Request(method, endpoint string, headers map[string]string, reqBody interface{}, respBody interface{}) error

Request sends an HTTP request with the specified method, headers, request body, and response structure.

func (*HTTPClient) SetTimeout

func (c *HTTPClient) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for the HTTP client.

func (*HTTPClient) SetUserAgent

func (c *HTTPClient) SetUserAgent(userAgent string)

SetUserAgent sets the User-Agent header for the HTTP client.

Jump to

Keyboard shortcuts

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