util

package
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxRedirects specifies the maximum number of redirects an HTTP
	// request should be able to make
	MaxRedirects = 5
)

Functions

func DELETE

func DELETE(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string) error

DELETE does a delete request to the account server

func GET

func GET(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string, res interface{}) error

GET does a get request to the account server, decoding the result into the object pointed to byres

func GETBody

func GETBody(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string) (io.ReadCloser, error)

GET does a get request to the account server, decoding the result into the object pointed to byres

func PATCH

func PATCH(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string, body, res interface{}) error

PATCH creates an HTTP Patch request to the specified server, with the body encoded as JSON, decoding the result into the object pointed to byres

func POST

func POST(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string, body, res interface{}) error

POST creates an HTTP Post request to the specified server, with the body encoded as JSON, decoding the result into the object pointed to byres

func PUT

func PUT(ctx log.Interface, server string, strategy auth.Strategy, URI string, headers map[string]string, body, res interface{}) error

PUT creates an HTTP Put request to the specified server, with the body encoded as JSON, decoding the result into the object pointed to byres

func Validate

func Validate(val interface{}) error

Validate recursivly validates most structures using govalidator struct tags. It currently works for slices, structs and pointers.

Types

type HTTPError

type HTTPError struct {
	Code    int    `json:"code"`
	Message string `json:"error"`
}

HTTPError represents an error coming over HTTP, it is not an error with executing the request itself, it is an error the server is flaggin to the client.

func (HTTPError) Error

func (e HTTPError) Error() string

type RoundTripper

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

func NewRoundTripper

func NewRoundTripper(ctx log.Interface, headers map[string]string) *RoundTripper

func (*RoundTripper) RoundTrip

func (t *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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