common

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeParams

func EscapeParams(params ...interface{}) []interface{}

Helper function for correctly formatting and escaping URL path parameters. Used in the generated API client code.

Types

type BadRequest

type BadRequest error

type Client

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

Client manages the REST interface for a calling user.

func MakeClient

func MakeClient(address string, apiHeader, apiToken string) (c *Client, err error)

MakeClient is the factory for constructing a Client for a given endpoint.

func MakeClientWithHeaders

func MakeClientWithHeaders(address string, apiHeader, apiToken string, headers []*Header) (c *Client, err error)

MakeClientWithHeaders is the factory for constructing a Client for a given endpoint with additional user defined headers.

func MakeClientWithTransport added in v2.1.0

func MakeClientWithTransport(address string, apiHeader, apiToken string, headers []*Header, transport http.RoundTripper) (c *Client, err error)

MakeClientWithTransport is the factory for constructing a Client for a given endpoint with a custom HTTP Transport as well as optional additional user defined headers.

func (*Client) Delete

func (client *Client) Delete(ctx context.Context, response interface{}, path string, params interface{}, headers []*Header) error

Delete performs a DELETE request to the specific path against the server

func (*Client) Get

func (client *Client) Get(ctx context.Context, response interface{}, path string, params interface{}, headers []*Header) error

Get performs a GET request to the specific path against the server

func (*Client) GetRaw

func (client *Client) GetRaw(ctx context.Context, path string, params interface{}, headers []*Header) (response []byte, err error)

GetRaw performs a GET request to the specific path against the server and returns the raw body bytes.

func (*Client) GetRawMsgpack

func (client *Client) GetRawMsgpack(ctx context.Context, response interface{}, path string, params interface{}, headers []*Header) error

GetRawMsgpack performs a GET request to the specific path against the server and returns the decoded messagepack response.

func (*Client) Post

func (client *Client) Post(ctx context.Context, response interface{}, path string, params interface{}, headers []*Header, body interface{}) error

Post sends a POST request to the given path with the given body object. No query parameters will be sent if body is nil. response must be a pointer to an object as post writes the response there.

type Header struct {
	Key   string
	Value string
}

Header is a struct for custom headers.

type InternalError

type InternalError error

type InvalidToken

type InvalidToken error

type NotFound

type NotFound error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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