rest

package
v1.9.11 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient added in v1.2.0

type APIClient interface {
	Delete(expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)
	Get(expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)
	Patch(expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)
	Post(data []byte, contentType string, expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)
	Put(data []byte, contentType string, expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)
}

APIClient defines the contract for a REST API client, the `expectedHeaders` argument being the names of the expected response headers returned by any call

type Client

type Client struct {
	// URL is the full URL (including protocol and eventual query string et al.)
	URL string

	// Headers is an optional map of name -> value tuples of HTTP request headers
	Headers map[string]string

	// Context gives the name of the calling context, eg. "rest"
	Context string
}

Client ...

func (*Client) Delete added in v1.2.0

func (c *Client) Delete(expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)

Delete uses the URL and/or the query string to define which resource to delete, eg.

DELETE http://www.example.com/account/123
DELETE http://www.example.com/account?id=123

func (*Client) Get

func (c *Client) Get(expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)

Get uses the URL and/or the query string to define what resource to get, eg.

GET http://www.example.com/account/123
GET http://www.example.com/account?id=123

func (*Client) Patch added in v1.2.0

func (c *Client) Patch(expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)

Patch uses the URL and/or the query string to define which specific resource to update, eg.

PATCH http://www.example.com/account/123/name/Doe
PATCH http://www.example.com/account?id=123&name=Doe

func (*Client) Post

func (c *Client) Post(data []byte, contentType string, expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)

Post uses the URL and/or the query string to define what type of resource to add

POST http://www.example.com/account

func (*Client) Put added in v1.2.0

func (c *Client) Put(data []byte, contentType string, expectedHeaders ...string) (statusCode int, body []byte, headers map[string]string, err error)

Put uses the URL and/or the query string to define which resource to update, eg.

PUT http://www.example.com/account/123
PUT http://www.example.com/account?id=123

Directories

Path Synopsis
header

Jump to

Keyboard shortcuts

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