package perigee

import "k8s.io/kubernetes/Godeps/_workspace/src/github.com/racker/perigee"

Index

Functions

func Delete

func Delete(url string, opts Options) error

Delete makes a DELETE request against a server using the provided HTTP client. The url must be a fully-formed URL string. DEPRECATED. Use Request() instead.

func Get

func Get(url string, opts Options) error

Get makes a GET request against a server using the provided HTTP client. The url must be a fully-formed URL string. DEPRECATED. Use Request() instead.

func Post

func Post(url string, opts Options) error

Post makes a POST request against a server using the provided HTTP client. The url must be a fully-formed URL string. DEPRECATED. Use Request() instead.

func Put

func Put(url string, opts Options) error

Put makes a PUT request against a server using the provided HTTP client. The url must be a fully-formed URL string. DEPRECATED. Use Request() instead.

Types

type Options

type Options struct {
	CustomClient  *http.Client
	ReqBody       interface{}
	Results       interface{}
	MoreHeaders   map[string]string
	OkCodes       []int
	StatusCode    *int    `DEPRECATED`
	DumpReqJson   bool    `UNSUPPORTED`
	ResponseJson  *[]byte `DEPRECATED`
	Response      **Response
	ContentType   string `json:"Content-Type,omitempty"`
	ContentLength int64  `json:"Content-Length,omitempty"`
	Accept        string `json:"Accept,omitempty"`
	SetHeaders    func(r *http.Request) error
}

Options describes a set of optional parameters to the various request calls.

The custom client can be used for a variety of purposes beyond selecting encrypted versus unencrypted channels. Transports can be defined to provide augmented logging, header manipulation, et. al.

If the ReqBody field is provided, it will be embedded as a JSON object. Otherwise, provide nil.

If JSON output is to be expected from the response, provide either a pointer to the container structure in Results, or a pointer to a nil-initialized pointer variable. The latter method will cause the unmarshaller to allocate the container type for you. If no response is expected, provide a nil Results value.

The MoreHeaders map, if non-nil or empty, provides a set of headers to add to those already present in the request. At present, only Accepted and Content-Type are set by default.

OkCodes provides a set of acceptable, positive responses.

If provided, StatusCode specifies a pointer to an integer, which will receive the returned HTTP status code, successful or not. DEPRECATED; use the Response.StatusCode field instead for new software.

ResponseJson, if specified, provides a means for returning the raw JSON. This is most useful for diagnostics. DEPRECATED; use the Response.JsonResult field instead for new software.

DumpReqJson, if set to true, will cause the request to appear to stdout for debugging purposes. This attribute may be removed at any time in the future; DO NOT use this attribute in production software.

Response, if set, provides a way to communicate the complete set of HTTP response, raw JSON, status code, and other useful attributes back to the caller. Note that the Request() method returns a Response structure as part of its public interface; you don't need to set the Response field here to use this structure. The Response field exists primarily for legacy or deprecated functions.

SetHeaders allows the caller to provide code to set any custom headers programmatically. Typically, this facility can invoke, e.g., SetBasicAuth() on the request to easily set up authentication. Any error generated will terminate the request and will propegate back to the caller.

type Response

type Response struct {
	HttpResponse http.Response
	JsonResult   []byte
	Results      interface{}
	StatusCode   int
}

func Request

func Request(method string, url string, opts Options) (*Response, error)

Request issues an HTTP request, marshaling parameters, and unmarshaling results, as configured in the provided Options parameter. The Response structure returned, if any, will include accumulated results recovered from the HTTP server. See the Response structure for more details.

type UnexpectedResponseCodeError

type UnexpectedResponseCodeError struct {
	Url      string
	Expected []int
	Actual   int
	Body     []byte
}

The UnexpectedResponseCodeError structure represents a mismatch in understanding between server and client in terms of response codes. Most often, this is due to an actual error condition (e.g., getting a 404 for a resource when you expect a 200). However, it needn't always be the case (e.g., getting a 204 (No Content) response back when a 200 is expected).

func (*UnexpectedResponseCodeError) Error

func (err *UnexpectedResponseCodeError) Error() string

Source Files

api.go

Version
v0.8.2
Published
Jan 20, 2015
Platform
js/wasm
Imports
7 packages
Last checked
40 minutes ago

Tools for package owners.