client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingEndpointEnv   = errors.New("missing environment variable KEYCTL_ENDPOINT")
	ErrMissingEndpointInURL = errors.New("missing host in URL")
	ErrMissingIDInURL       = errors.New("missing ID in URL")
	ErrUnsupportedScheme    = errors.New("unsupported scheme")
	ErrMissingEndpoint      = errors.New("missing Endpoint in config")
)
View Source
var (
	ErrNotFound = errors.New("not found")
)
View Source
var ErrRedirect = Redirect{}

Functions

func KeyFromURL

func KeyFromURL(url string) (id, share string, err error)

Types

type Client

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

func NewClient

func NewClient(options ...ClientOption) *Client

func (*Client) Do

func (c *Client) Do(r *http.Request, v any) (resp *http.Response, err error)

func (*Client) FollowRedirect

func (c *Client) FollowRedirect(r *http.Request, v any, delay time.Duration) (resp *http.Response, err error)

func (*Client) FollowRedirectLoop

func (c *Client) FollowRedirectLoop(r *http.Request, v any, delay time.Duration) (resp *http.Response, err error)

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error)

type ClientOption

type ClientOption func(*Client)

func ClientOptionsFromConfig

func ClientOptionsFromConfig(cfg Config) (options []ClientOption, err error)

func ClientOptionsFromEnv

func ClientOptionsFromEnv() (options []ClientOption, err error)

func ClientOptionsFromURL

func ClientOptionsFromURL(url string) (options []ClientOption, err error)

func WithDebugWriter

func WithDebugWriter(debugWriter io.Writer) ClientOption

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

type Config

type Config struct {
	Endpoint string `json:"endpoint"`
}

type Error

type Error struct {
	Err  string `json:"error"`
	Code int    `json:"code"`
}

func (Error) Error

func (e Error) Error() string

func (Error) Is

func (e Error) Is(target error) bool

type Redirect

type Redirect struct {
	Location string
	Code     int
}

func (Redirect) Error

func (r Redirect) Error() string

Jump to

Keyboard shortcuts

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