utils

package
v0.0.0-...-9d69390 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2015 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(location *url.URL) string

func HttpAcceptType

func HttpAcceptType(request *http.Request) string

Retrieve the http accept type of defaults

request:		the http request pointer

func HttpContentType

func HttpContentType(request *http.Request) string

Retrieve the content-type from the header of the request

request:		the http request

func HttpJsonDecode

func HttpJsonDecode(request io.ReadCloser, size int64, data interface{}) error

func HttpJsonEncode

func HttpJsonEncode(body io.ReadCloser, size int64, data interface{}) ([]byte, error)

func HttpJsonRequest

func HttpJsonRequest(method, location string, payload, result interface{}, timeout time.Duration) error

Essentially a wrapper for the HttpJsonSend method

method:			the http method e.g. get, post etc
location:		the full url for the endpoint
payload:		a pointer to a structure which needs to be sent with the request
result:			the structure we should decode the output into

func HttpJsonSend

func HttpJsonSend(method, location string, payload, result interface{}, timeout time.Duration) (int, error)

Performs a json request and decodes the result for us

method:			the http method e.g. get, post etc
location:		the full url for the endpoint
payload:		a pointer to a structure which needs to be sent with the request
result:			the structure we should decode the output into

func IsJsonContent

func IsJsonContent(r *http.Request) bool

func JsonDecode

func JsonDecode(content []byte, result interface{}) error

Decode the content and place into the result structure

content:		a string which hopefully contains some json object
result:			a structure you want to unmarshall the data into

func JsonEncode

func JsonEncode(data interface{}) ([]byte, error)

Encode the data structure in a json string

data:		the structure you wish to marshal into json

func RandomUUID

func RandomUUID(min int) string

Generate a random number string of x amount

min:		the length of the string you want generated

func ReadHttpContentBody

func ReadHttpContentBody(body io.ReadCloser, length int64) ([]byte, error)

Read in the contents of a request

body:		the io reader from the request / response
length:		the length of the content

func TransferBytes

func TransferBytes(src io.Reader, dest io.Writer, wg *sync.WaitGroup) (int64, error)

Transfer bytes from the src to destination

	src:		the source for the data
 dest:		the destination to write the data
	wg:			a pointer to a wait group to indicate when complete

Types

This section is empty.

Jump to

Keyboard shortcuts

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