googleapi

package
v0.0.0-...-0d8a8f5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2014 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package googleapi contains the common code shared by all Google API libraries.

Index

Constants

View Source
const Version = "0.5"

Variables

View Source
var WithDataWrapper = MarshalStyle(true)
View Source
var WithoutDataWrapper = MarshalStyle(false)

Functions

func CheckResponse

func CheckResponse(res *http.Response) error

CheckResponse returns an error (of type *Error) if the response status code is not 2xx.

func CloseBody

func CloseBody(res *http.Response)

CloseBody is used to close res.Body. Prior to calling Close, it also tries to Read a small amount to see an EOF. Not seeing an EOF can prevent HTTP Transports from reusing connections.

func CombineFields

func CombineFields(s []Field) string

CombineFields combines fields into a single string.

func ConditionallyIncludeMedia

func ConditionallyIncludeMedia(media io.Reader, bodyp *io.Reader, ctypep *string) (totalContentLength int64, ok bool)

ConditionallyIncludeMedia does nothing if media is nil.

bodyp is an in/out parameter. It should initially point to the reader of the application/json (or whatever) payload to send in the API request. It's updated to point to the multipart body reader.

ctypep is an in/out parameter. It should initially point to the content type of the bodyp, usually "application/json". It's updated to the "multipart/related" content type, with random boundary.

The return value is the content-length of the entire multpart body.

func