rest

package
v0.0.0-...-0111df2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: Apache-2.0 Imports: 4 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 {
	// contains filtered or unexported fields
}

Client is a basic HTTP client for REST operations

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient constructs a new REST client for the given config

func (*Client) Delete

func (c *Client) Delete(path string) error

Delete deletes the resource at the given path or returns an error

func (*Client) Get

func (c *Client) Get(path string, output interface{}) error

Get gets a resource at the given path and stores the result in output or returns an error

func (*Client) Patch

func (c *Client) Patch(path string, body interface{}, output interface{}) error

Patch patches the body to the given path and stores the response in output or returns an error

func (*Client) Post

func (c *Client) Post(path string, body interface{}, output interface{}) error

Post posts the body to the given path and stores the response in output or returns an error

type Config

type Config struct {
	BaseURL      string
	Token        string
	DebugEnabled bool
}

Config is the configuration for a REST client

type HTTPError

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

HTTPError implements the error interface for an HTTP-related error

func (HTTPError) Error

func (e HTTPError) Error() string

Error returns a string representing this error

func (HTTPError) IsNotFound

func (e HTTPError) IsNotFound() bool

IsNotFound returns true if this is a "not found" error, else false

type Interface

type Interface interface {
	Get(path string, output interface{}) error
	Delete(path string) error
	Post(path string, body interface{}, output interface{}) error
	Patch(path string, body interface{}, output interface{}) error
}

Interface is the set of REST actions available

Jump to

Keyboard shortcuts

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