httpclient

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPError

type HTTPError struct {
	StatusCode int
	Status     string
}

HTTPError represents an HTTP error returned by a server.

func (HTTPError) Error

func (err HTTPError) Error() string

Error returns a string representation of the HTTP error.

No parameters. Returns a string.

type HttpClient

type HttpClient struct {
	Client    *http.Client
	UserAgent string
}

func New

func New(userAgent *string) *HttpClient

New initializes a new HttpClient with the provided user agent.

userAgent: A pointer to a string containing the user agent. Returns a pointer to a HttpClient.

func (*HttpClient) Get

func (c *HttpClient) Get(link *url.URL) ([]byte, error)

Get retrieves data from the specified URL using an HTTP GET request.

Parameters: - link: A pointer to a url.URL struct representing the URL to send the request to. Returns: - []byte: The response body as a byte slice. - error: An error if the request fails or the response status code is not in the 200-299 range.

Jump to

Keyboard shortcuts

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