api

package
v0.0.0-...-97b4fb6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

api provides common functionality for all the iron.io APIs

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug            bool
	DebugOnErrors    bool
	DefaultCacheSize = 8192

	// HttpClient is the client used by iron_go to make each http request. It is exported in case
	// the client would like to modify it from the default behavior from http.DefaultClient.
	// This uses the DefaultTransport modified to enable TLS Session Client caching.
	HttpClient = &http.Client{
		Transport: &http.Transport{
			Proxy: http.ProxyFromEnvironment,
			Dial: (&net.Dialer{
				Timeout:   30 * time.Second,
				KeepAlive: 30 * time.Second,
			}).Dial,
			MaxIdleConnsPerHost: 512,
			TLSHandshakeTimeout: 10 * time.Second,
			TLSClientConfig: &tls.Config{
				ClientSessionCache: tls.NewLRUClientSessionCache(DefaultCacheSize),
			},
		},
	}
)
View Source
var HTTPErrorDescriptions = map[int]string{
	http.StatusUnauthorized:     "The OAuth token is either not provided or invalid",
	http.StatusNotFound:         "The resource, project, or endpoint being requested doesn't exist.",
	http.StatusMethodNotAllowed: "This endpoint doesn't support that particular verb",
	http.StatusNotAcceptable:    "Required fields are missing",
}
View Source
var MaxRequestRetries = 5

Functions

This section is empty.

Types

type DefaultResponseBody

type DefaultResponseBody struct {
	Msg string `json:"msg"`
}

type HTTPResponseError

type HTTPResponseError interface {
	Error() string
	StatusCode() int
}

func ResponseAsError

func ResponseAsError(response *http.Response) HTTPResponseError

type URL

type URL struct {
	URL      url.URL
	Settings config.Settings
}

func Action

func Action(cs config.Settings, prefix string, suffix ...string) *URL

func ActionEndpoint

func ActionEndpoint(cs config.Settings, endpoint string) *URL

func VersionAction

func VersionAction(cs config.Settings) *URL

func (*URL) QueryAdd

func (u *URL) QueryAdd(key string, format string, value interface{}) *URL

func (*URL) Req

func (u *URL) Req(method string, in, out interface{}) error

func (*URL) Request

func (u *URL) Request(method string, body io.Reader) (response *http.Response, err error)

returned body must be closed by caller if non-nil

Jump to

Keyboard shortcuts

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