httputil

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSONResponse

func DecodeJSONResponse(resp *http.Response, obj interface{}) error

func DoRequest

func DoRequest(req *http.Request) (*http.Response, error)

func Ensure2XX

func Ensure2XX(resp *http.Response) error

func GetRedirectLocation

func GetRedirectLocation(resp *http.Response) (loc *url.URL, err error)

func JSONRequest

func JSONRequest(method string, uri string, payload interface{}) (*http.Request, error)

func PostFormUrlencoded

func PostFormUrlencoded(client *http.Client, url string, modifyRequest func(r *http.Request), values url.Values) (*http.Response, error)

func WithAccessToken

func WithAccessToken(req *http.Request, token string) *http.Request

func WithClient

func WithClient(req *http.Request, client *http.Client) *http.Request

Types

type Authenticator

type Authenticator interface {
	Authenticate(client *http.Client) (*ClientCreds, error)
}

type Client

type Client struct {
	Client *http.Client

	Authenticator Authenticator
	Logger        logr.Logger
	// contains filtered or unexported fields
}

func (*Client) CreateObject

func (c *Client) CreateObject(endpoint string, payload, response interface{}) (err error)

func (*Client) DeleteObject

func (c *Client) DeleteObject(endpoint string) (err error)

func (*Client) DoRequest

func (c *Client) DoRequest(req *http.Request) (resp *http.Response, err error)

func (*Client) Get

func (c *Client) Get(url string) (resp *http.Response, err error)

func (*Client) GetObject added in v0.3.0

func (c *Client) GetObject(endpoint string, response interface{}) (err error)

func (*Client) ListObjects

func (c *Client) ListObjects(endpoint string, urlQuery url.Values, response interface{}) (err error)

func (*Client) PostFormUrlencoded

func (c *Client) PostFormUrlencoded(url string, modifyRequest func(r *http.Request), values url.Values) (*http.Response, error)

func (*Client) UpdateObject

func (c *Client) UpdateObject(endpoint string, payload interface{}) (err error)

type ClientCreds

type ClientCreds struct {
	AccessToken      string `json:"access_token,omitempty"`
	ExpiresIn        int    `json:"expires_in,omitempty"`
	RefreshExpiresIn int    `json:"refresh_expires_in,omitempty"`
	RefreshToken     string `json:"refresh_token,omitempty"`
	TokenType        string `json:"token_type,omitempty"`
	// contains filtered or unexported fields
}

type ErrUnanticipatedResponse

type ErrUnanticipatedResponse struct {
	Status      int
	ContentType string
	Body        string
}

func NewErrUnanticipatedResponse added in v0.4.2

func NewErrUnanticipatedResponse(resp *http.Response) *ErrUnanticipatedResponse

func (ErrUnanticipatedResponse) Error added in v0.4.2

func (err ErrUnanticipatedResponse) Error() string

Jump to

Keyboard shortcuts

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