func (c *Client) GetResource(id *charm.URL, name string, revision int) (result ResourceData, err error) {
	// Create the request.
	req, err := http.NewRequest("GET", "", nil)
	if err != nil {
		return result, errgo.Notef(err, "cannot make new request")
	}

	url := "/" + id.Path() + "/resource/" + name
	if revision >= 0 {
		url += "/" + strconv.Itoa(revision)
	}
	resp, err := c.Do(req, url)
	if err != nil {
		return result, errgo.NoteMask(err, "cannot get resource", isAPIError)
	}
	defer func() {
		if err != nil {
			resp.Body.Close()
		}
	}()

	// Validate the response headers.
	hash := resp.Header.Get(params.ContentHashHeader)
	if hash == "" {
		return result, errgo.Newf("no %s header found in response", params.ContentHashHeader)
	}

	return ResourceData{
		ReadCloser: resp.Body,
		Size:       resp.ContentLength,
		Hash:       hash,
	}, nil
}
// GetResource retrieves byes of the resource with the given name and revision
// for the given charm, returning a reader its data can be read from,  the
// SHA384 hash of the data.
//
// If revision is negative, the currently published resource for the Client's
// channel will be returned.
//
// Note that the result must be closed after use.
GetResource retrieves byes of the resource with the given name and revision
for the given charm, returning a reader its data can be read from,  the
SHA384 hash of the data.

If revision is negative, the currently published resource for the Client's
channel will be returned.

Note that the result must be closed after use.
// GetResource retrieves byes of the resource with the given name and revision // for the given charm returning a reader its data can be read from the // SHA384 hash of the data . // // If revision is negative the currently published resource for the Client ' s // channel will be returned . // // Note that the result must be closed after use .
func (c *Client) GetResource(id *charm.URL, name string, revision int) (result ResourceData, err error) {
	req, err := http.NewRequest("GET", "", nil)
	if err != nil {
		return result, errgo.Notef(err, "cannot make new request")
	}
	url := "/" + id.Path() + "/resource/" + name
	if revision >= 0 {
		url += "/" + strconv.Itoa(revision)
	}
	resp, err := c.Do(req, url)
	if err != nil {
		return result, errgo.NoteMask(err, "cannot get resource", isAPIError)
	}
	defer func() {
		if err != nil {
			resp.Body.Close()
		}
	}()
	hash := resp.Header.Get(params.ContentHashHeader)
	if hash == "" {
		return result, errgo.Newf("no %s header found in response", params.ContentHashHeader)
	}
	return ResourceData{
		ReadCloser: resp.Body,
		Size:       resp.ContentLength,
		Hash:       hash,
	}, nil
}
func ( c * Client ) GetResource ( id * charm . URL , name string , revision int ) ( result ResourceData , err error ) { req , err := http . NewRequest ( " " , " " , nil ) if err != nil { return result , errgo . Notef ( err , " " ) } url := " " + id . Path ( ) + " " + name if revision >= 0 { url += " " + strconv . Itoa ( revision ) } resp , err := c . Do ( req , url ) if err != nil { return result , errgo . NoteMask ( err , " " , isAPIError ) } defer func ( ) { if err != nil { resp . Body . Close ( ) } } ( ) hash := resp . Header . Get ( params . ContentHashHeader ) if hash == " " { return result , errgo . Newf ( " " , params . ContentHashHeader ) } return ResourceData { ReadCloser : resp . Body , Size : resp . ContentLength , Hash : hash , } , nil }
GetResource retrieves byes of the resource with the given name and revision
for the given charm, returning a reader its data can be read from,  the
SHA384 hash of the data.
GetResource retrieves byes of the resource with the given name and revision for the given charm returning a reader its data can be read from the SHA384 hash of the data .
// Create the request. // Validate the response headers.