client

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadResponseBody

func ReadResponseBody(resp *http.Response) (string, error)

ReadResponseBody reads and returns the response body Parameters: - resp: *http.Response - The response to read body from Returns: - string: The response body as string - error: Any error that occurred during reading

Types

type HTTPClient

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

HTTPClient represents a configured HTTP client

func NewHTTPClient

func NewHTTPClient(cfg *config.Config) *HTTPClient

NewHTTPClient creates a new HTTP client with configuration Parameters: - cfg: *config.Config - Configuration containing timeout and other settings Returns: - *HTTPClient: A configured HTTP client instance

func (*HTTPClient) CreateDeleteRequest added in v0.4.0

func (c *HTTPClient) CreateDeleteRequest(url string, headers map[string]string) (*http.Request, error)

CreateDeleteRequest creates a new DELETE request Parameters: - url: string - The URL to send DELETE request to - headers: map[string]string - Optional headers to include Returns: - *http.Request: The created DELETE request - error: Any error that occurred during request creation

func (*HTTPClient) CreateGetRequest

func (c *HTTPClient) CreateGetRequest(url string, headers map[string]string) (*http.Request, error)

CreateGetRequest creates a new GET request Parameters: - url: string - The URL to send GET request to - headers: map[string]string - Optional headers to include Returns: - *http.Request: The created GET request - error: Any error that occurred during request creation

func (*HTTPClient) CreatePostRequest

func (c *HTTPClient) CreatePostRequest(url string, headers map[string]string, body string) (*http.Request, error)

CreatePostRequest creates a new POST request Parameters: - url: string - The URL to send POST request to - headers: map[string]string - Optional headers to include - body: string - The request body Returns: - *http.Request: The created POST request - error: Any error that occurred during request creation

func (*HTTPClient) CreatePutRequest added in v0.4.0

func (c *HTTPClient) CreatePutRequest(url string, headers map[string]string, body string) (*http.Request, error)

CreatePutRequest creates a new PUT request Parameters: - url: string - The URL to send PUT request to - headers: map[string]string - Optional headers to include - body: string - The request body Returns: - *http.Request: The created PUT request - error: Any error that occurred during request creation

func (*HTTPClient) SendRequest

func (c *HTTPClient) SendRequest(req *http.Request) (*http.Response, error)

SendRequest sends an HTTP request and returns the response Parameters: - req: *http.Request - The request to send Returns: - *http.Response: The response from the server - error: Any error that occurred during the request

func (*HTTPClient) SetHeaders

func (c *HTTPClient) SetHeaders(req *http.Request, headers map[string]string)

SetHeaders sets headers for an HTTP request Parameters: - req: *http.Request - The request to set headers for - headers: map[string]string - Headers to set

Jump to

Keyboard shortcuts

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