http

package
v2.13.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(resp *http.Response) error

CheckResponse checks the API response for errors, and returns them if present.

Types

type Client

type Client struct {

	// UserAgent is the user agent to include in HTTP requests.
	UserAgent string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL string, options ...ClientOptionFunc) (*Client, error)

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body interface{}, options []ClientOptionFunc) (*http.Request, error)

type ClientOptionFunc

type ClientOptionFunc func(*Client) error

ClientOptionFunc can be used to customize a new Restful API client.

func WithTimeout

func WithTimeout(timeout int) ClientOptionFunc

WithTimeout can be used to configure a custom timeout for requests.

func WithToken

func WithToken(token string) ClientOptionFunc

WithToken is an option for NewClient to set token

type ErrorResponse

type ErrorResponse struct {
	Body     []byte
	Response *http.Response
	Message  string
}

Jump to

Keyboard shortcuts

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