http

package
v0.0.0-...-afa1830 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MimeTypeBlank          = ""
	MimeTypeHead           = "head"
	MimeTypeJSON           = "application/json"
	MimeTypeMultipartForm  = "multipart/form-data"
	MimeTypeURLEncodedForm = "application/x-www-form-urlencoded"
)

HTTP formats

Variables

This section is empty.

Functions

func IgnoreInsecureHTTPS

func IgnoreInsecureHTTPS() func(*Client)

IgnoreInsecureHTTPS certificates shall never be used in production

func IgnoreProtocol

func IgnoreProtocol() func(*Client)

IgnoreProtocol by setting corresponding boolean to true

func SetAuthenticator

func SetAuthenticator(authenticator authenticator) func(*Client)

SetAuthenticator sets the optional authenticator on the http client number of retries

func SetFormat

func SetFormat(format string) func(*Client)

SetFormat of the client by override some HTTP verb corresponding methods

Types

type Client

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

Client represents a HTTP REST API client requesting a configured endpoint.

func NewClient

func NewClient(url string, secure bool, options ...func(*Client)) *Client

NewClient is HTTP Client constructor

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, route string, params url.Values) error

Delete ... Fixed HTTP method Delete an entity using route as base url then params as query parameters A delete request is agnostic from the format since no body input/output is considered

func (*Client) Get

func (r *Client) Get(ctx context.Context, route string, params url.Values, output interface{}) error

Get ... Overridable HTTP method Get an entity using route as base url then params as query parameters

func (*Client) Head

func (r *Client) Head(ctx context.Context, route string, params url.Values, output map[string][]string) error

Head ... Fixed HTTP method Head entity using route as base url then params as query parameters A head request is agnostic from the format since no body input/output format is considered the output is built based on http headers

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, route string, input interface{}) error

Patch ... Overridable HTTP method patch an entity using route as base url

func (*Client) Perform

func (r *Client) Perform(
	ctx context.Context,
	verb string,
	route string,
	params url.Values,
	input interface{},
	output interface{},
	format string,
) error

Perform ...

func (*Client) Post

func (r *Client) Post(ctx context.Context, route string, params url.Values, input interface{}, output interface{}) error

Post ... Overridable HTTP method post an entity using route as base url then params as query parameters

func (*Client) Put

func (r *Client) Put(ctx context.Context, route string, params url.Values, input interface{}, output interface{}) error

Put ... Overridable HTTP method put an entity using route as base url then params as query parameters

type MultipartRequest

type MultipartRequest struct {
	Body        *bytes.Buffer
	ContentType string
	Output      interface{}
}

MultipartRequest ...

Jump to

Keyboard shortcuts

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