httputil

package
v3.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const YorcAPIDefaultErrorMsg = "Failed to contact Yorc API"

YorcAPIDefaultErrorMsg is the default communication error message

Variables

This section is empty.

Functions

func ErrExit

func ErrExit(msg interface{})

ErrExit allows to exit on error with exit code 1 after printing error message

func GetJSONEntityFromAtomGetRequest

func GetJSONEntityFromAtomGetRequest(client *YorcClient, atomLink rest.AtomLink, entity interface{}) error

GetJSONEntityFromAtomGetRequest returns JSON entity from AtomLink request

func HandleHTTPStatusCode

func HandleHTTPStatusCode(response *http.Response, resourceID string, resourceType string, expectedStatusCodes ...int)

HandleHTTPStatusCode handles Yorc HTTP status code and displays error if needed

func HandleHTTPStatusCodeWithCustomizedErrorMessage

func HandleHTTPStatusCodeWithCustomizedErrorMessage(
	response *http.Response,
	resourceID string,
	resourceType string,
	customizedErrorMessages map[string]string,
	expectedStatusCodes ...int)

HandleHTTPStatusCodeWithCustomizedErrorMessage handles Yorc HTTP status code and in case of error, can display a customized error message instead of the source error if this source error contains a given string provided as key in the map argument customizedErrorMessages

func PrintErrors

func PrintErrors(body io.Reader)

PrintErrors allows to print REST errors

Types

type YorcClient

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

YorcClient is the Yorc HTTP client structure

func GetClient

func GetClient(cc config.Client) (*YorcClient, error)

GetClient returns a yorc HTTP Client

func (*YorcClient) Get

func (c *YorcClient) Get(path string) (*http.Response, error)

Get returns a new HTTP request with GET method

func (*YorcClient) Head

func (c *YorcClient) Head(path string) (*http.Response, error)

Head returns a new HTTP request with HEAD method

func (*YorcClient) NewRequest

func (c *YorcClient) NewRequest(method, path string, body io.Reader) (*http.Request, error)

NewRequest returns a new HTTP request

func (*YorcClient) Post

func (c *YorcClient) Post(path string, contentType string, body io.Reader) (*http.Response, error)

Post returns a new HTTP request with Post method

func (*YorcClient) PostForm

func (c *YorcClient) PostForm(path string, data url.Values) (*http.Response, error)

PostForm returns a new HTTP request with Post method and form content

Jump to

Keyboard shortcuts

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