Documentation ¶
Index ¶
- Constants
- func AttachToRequest(req *http.Request, attached io.Reader, meta interface{}, name string) error
- func ExtractAPIError(resp *http.Response) (*params.Error, error)
- func ExtractJSONResult(resp *http.Response, result interface{}) error
- func ExtractRequestAttachment(req *http.Request, metaResult interface{}) (io.ReadCloser, error)
- func NewRequest(method string, baseURL *url.URL, pth, uuid, tag, pw string) (*http.Request, error)
- func SetRequestArgs(req *http.Request, args interface{}) error
- type DigestAlgorithm
Constants ¶
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 ¶
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 ¶
ExtractAPIError returns the failure serialized in the response body. If there is no failure (an OK status code), it simply returns nil.
func ExtractJSONResult ¶
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 ¶
NewRequest returns a new HTTP request suitable for the API.
func SetRequestArgs ¶
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.