func (c *Client) NewTokenRequest(token, method, path string, query *url.Values,
	body interface{}) (*http.Request, error) {

	b := &bytes.Buffer{}
	if body != nil {
		enc := json.NewEncoder(b)
		err := enc.Encode(body)
		if err != nil {
			return nil, err
		}
	}

	if query == nil {
		query = &url.Values{}
	}

	fullPath := c.prefix + path
	if q := query.Encode(); q != "" {
		fullPath += "?" + q
	}

	req, err := http.NewRequest(method, fullPath, b)
	if err != nil {
		return nil, err
	}

	if token != "" {
		req.Header.Set("Authorization", "Bearer "+token)
	}

	req.Header.Set("Host", c.prefix)
	req.Header.Set("User-Agent", "Torus-Daemon/"+c.version)
	req.Header.Set("Content-type", "application/json")
	req.Header.Set("X-Registry-Version", c.apiVersion)

	return req, nil
}
// NewTokenRequest constructs a new http.Request, with a body containing the
// json representation of body, if provided.
//
// The request will be authorized with the provided token.
NewTokenRequest constructs a new http.Request, with a body containing the
json representation of body, if provided.

The request will be authorized with the provided token.
// NewTokenRequest constructs a new http . Request with a body containing the // json representation of body if provided . // // The request will be authorized with the provided token .
func (c *Client) NewTokenRequest(token, method, path string, query *url.Values,
	body interface{}) (*http.Request, error) {
	b := &bytes.Buffer{}
	if body != nil {
		enc := json.NewEncoder(b)
		err := enc.Encode(body)
		if err != nil {
			return nil, err
		}
	}
	if query == nil {
		query = &url.Values{}
	}
	fullPath := c.prefix + path
	if q := query.Encode(); q != "" {
		fullPath += "?" + q
	}
	req, err := http.NewRequest(method, fullPath, b)
	if err != nil {
		return nil, err
	}
	if token != "" {
		req.Header.Set("Authorization", "Bearer "+token)
	}
	req.Header.Set("Host", c.prefix)
	req.Header.Set("User-Agent", "Torus-Daemon/"+c.version)
	req.Header.Set("Content-type", "application/json")
	req.Header.Set("X-Registry-Version", c.apiVersion)
	return req, nil
}
func ( c * Client ) NewTokenRequest ( token , method , path string , query * url . Values , body interface { } ) ( * http . Request , error ) { b := & bytes . Buffer { } if body != nil { enc := json . NewEncoder ( b ) err := enc . Encode ( body ) if err != nil { return nil , err } } if query == nil { query = & url . Values { } } fullPath := c . prefix + path if q := query . Encode ( ) ; q != " " { fullPath += " " + q } req , err := http . NewRequest ( method , fullPath , b ) if err != nil { return nil , err } if token != " " { req . Header . Set ( " " , " " + token ) } req . Header . Set ( " " , c . prefix ) req . Header . Set ( " " , " " + c . version ) req . Header . Set ( " " , " " ) req . Header . Set ( " " , c . apiVersion ) return req , nil }
NewTokenRequest constructs a new http.Request, with a body containing the
json representation of body, if provided.
NewTokenRequest constructs a new http . Request with a body containing the json representation of body if provided .