http

package
v0.0.0-...-be26699 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2015 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DigestSHA is the HTTP digest algorithm value used in juju's HTTP code.
	DigestSHA DigestAlgorithm = "SHA"

	// CTypeJSON is the HTTP content-type value used for JSON content.
	CTypeJSON = "application/json"
	// CTypeRaw is the HTTP content-type value used for raw, unformattedcontent.
	CTypeRaw = "application/octet-stream"
)

Variables

This section is empty.

Functions

func AttachToRequest

func AttachToRequest(req *http.Request, attached io.Reader, meta interface{}, name string) error

AttachToRequest attaches a reader's data to the request body as multi-part data, along with associated metadata. "name" is used to identify the attached "file", so a filename is an appropriate value.

func ExtractAPIError

func ExtractAPIError(resp *http.Response) (*params.Error, error)

ExtractAPIError returns the failure serialized in the response body. If there is no failure (an OK status code), it simply returns nil.

func ExtractJSONResult

func ExtractJSONResult(resp *http.Response, result interface{}) error

ExtractJSONResult unserializes the JSON-encoded result into the provided struct.

func ExtractRequestAttachment

func ExtractRequestAttachment(req *http.Request, metaResult interface{}) (io.ReadCloser, error)

ExtractRequestAttachment extracts the attached file and its metadata from the multipart data in the request.

func NewRequest

func NewRequest(method string, baseURL *url.URL, pth, uuid, tag, pw string) (*http.Request, error)

NewRequest returns a new HTTP request suitable for the API.

func SetRequestArgs

func SetRequestArgs(req *http.Request, args interface{}) error

SetRequestArgs JSON-encodes the args and sets them as the request body.

Types

type DigestAlgorithm

type DigestAlgorithm string

DigestAlgorithm is one of the values in the IANA registry. See RFC 3230 and 5843.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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