googleapi

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2014 License: Apache-2.0 Imports: 12 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 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 ResolveRelative

func ResolveRelative(basestr, relstr string) string

func SetOpaque

func SetOpaque(u *url.URL)

SetOpaque sets u.Opaque from u.Path such that HTTP requests to it don't alter any hex-escaped characters in u.Path.

Types

type ContentTyper

type ContentTyper interface {
	ContentType() string
}

ContentTyper is an interface for Readers which know (or would like to override) their Content-Type. If a media body doesn't implement ContentTyper, the type is sniffed from the content using http.DetectContentType.

type Error

type Error struct {
	// Code is the HTTP response status code and will always be populated.
	Code int `json:"code"`
	// Message is the server response message and is only populated when
	// explicitly referenced by the JSON server response.
	Message string `json:"message"`
	// Body is the raw response returned by the server.
	// It is often but not always JSON, depending on how the request fails.
	Body string
}

Error contains an error response from the server.

func (*Error) Error

func (e *Error) Error() string

type Float64s

type Float64s []float64

Float64s is a slice of float64s that marshal as quoted strings in JSON.

func (Float64s) MarshalJSON

func (s Float64s) MarshalJSON() ([]byte, error)

func (*Float64s) UnmarshalJSON

func (q *Float64s) UnmarshalJSON(raw []byte) error

type Int32s

type Int32s []int32

Int32s is a slice of int32s that marshal as quoted strings in JSON.

func (Int32s) MarshalJSON

func (s Int32s) MarshalJSON() ([]byte, error)

func (*Int32s) UnmarshalJSON

func (q *Int32s) UnmarshalJSON(raw []byte) error

type Int64s

type Int64s []int64

Int64s is a slice of int64s that marshal as quoted strings in JSON.

func (Int64s) MarshalJSON

func (s Int64s) MarshalJSON() ([]byte, error)

func (*Int64s) UnmarshalJSON

func (q *Int64s) UnmarshalJSON(raw []byte) error

type Lengther

type Lengther interface {
	Len() int
}

type MarshalStyle

type MarshalStyle bool

func (MarshalStyle) JSONReader

func (wrap MarshalStyle) JSONReader(v interface{}) (io.Reader, error)

type Uint32s

type Uint32s []uint32

Uint32s is a slice of uint32s that marshal as quoted strings in JSON.

func (Uint32s) MarshalJSON

func (s Uint32s) MarshalJSON() ([]byte, error)

func (*Uint32s) UnmarshalJSON

func (q *Uint32s) UnmarshalJSON(raw []byte) error

type Uint64s

type Uint64s []uint64

Uint64s is a slice of uint64s that marshal as quoted strings in JSON.

func (Uint64s) MarshalJSON

func (s Uint64s) MarshalJSON() ([]byte, error)

func (*Uint64s) UnmarshalJSON

func (q *Uint64s) UnmarshalJSON(raw []byte) error

Directories

Path Synopsis
Package transport contains HTTP transports used to make authenticated API requests.
Package transport contains HTTP transports used to make authenticated API requests.

Jump to

Keyboard shortcuts

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