rest

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...Options) *Client

func (*Client) Auth

func (c *Client) Auth(ctx context.Context, clientid string, clientsecret *config.Plaintext)

Auth with client ID and Secret. If clientid is empty just return, allowing callers to call with config values even when not set.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, endpoint string, request any) (resp *http.Response, err error)

Delete Method

func (*Client) Get

func (c *Client) Get(ctx context.Context, endpoint string, request any, response any) (resp *http.Response, err error)

Get method. On successful return the response body will be closed.

func (*Client) Post

func (c *Client) Post(ctx context.Context, endpoint string, request any, response any) (resp *http.Response, err error)

Post method

func (*Client) Put

func (c *Client) Put(ctx context.Context, endpoint string, request any, response any) (resp *http.Response, err error)

PUT method

func (*Client) SetAuth

func (c *Client) SetAuth(header, value string)

SetAuth sets an explicit auth head and value for clients that do not use OAUTH etc.

type Options

type Options func(*restOptions)

Options are used to control behaviour of ICP functions

func BaseURL

func BaseURL(baseurl string) Options

BaseURL sets the root of the REST API URL. The default is "https://localhost:443"

func HTTPClient

func HTTPClient(client *http.Client) Options

HTTPClient sets the http.Client to use for requests. The default is the default http package client.

Jump to

Keyboard shortcuts

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