func (c *caller) prepareRequest(method, urlStr string, params *Parameters) (*http.Request, error) {
	if params == nil {
		params = &Parameters{}
	}
	var request *http.Request
	var err error
	if method == "GET" || method == "HEAD" {
		// These allow only URL encoded.
		request, err = http.NewRequest(method, urlStr, nil)
		if err != nil {
			return nil, errors.Annotate(err, ErrCannotPrepareRequest, errorMessages)
		}
		values, err := params.values()
		if err != nil {
			return nil, err
		}
		request.URL.RawQuery = values.Encode()
		request.Header.Set("Content-Type", rest.ContentTypeURLEncoded)
	} else {
		// Here use the body for content.
		body, err := params.body()
		if err != nil {
			return nil, err
		}
		request, err = http.NewRequest(method, urlStr, body)
		if err != nil {
			return nil, errors.Annotate(err, ErrCannotPrepareRequest, errorMessages)
		}
		request.Header.Set("Content-Type", params.ContentType)
	}
	if params.Version != nil {
		request.Header.Set("Version", params.Version.String())
	}
	if params.Token != nil {
		request = jwt.AddToRequest(request, params.Token)
	}
	if params.Accept == "" {
		params.Accept = params.ContentType
	}
	if params.Accept != "" {
		request.Header.Set("Accept", params.Accept)
	}
	return request, nil
}
// prepareRequest prepares the request to perform.
prepareRequest prepares the request to perform.
// prepareRequest prepares the request to perform .
func (c *caller) prepareRequest(method, urlStr string, params *Parameters) (*http.Request, error) {
	if params == nil {
		params = &Parameters{}
	}
	var request *http.Request
	var err error
	if method == "GET" || method == "HEAD" {
		request, err = http.NewRequest(method, urlStr, nil)
		if err != nil {
			return nil, errors.Annotate(err, ErrCannotPrepareRequest, errorMessages)
		}
		values, err := params.values()
		if err != nil {
			return nil, err
		}
		request.URL.RawQuery = values.Encode()
		request.Header.Set("Content-Type", rest.ContentTypeURLEncoded)
	} else {
		body, err := params.body()
		if err != nil {
			return nil, err
		}
		request, err = http.NewRequest(method, urlStr, body)
		if err != nil {
			return nil, errors.Annotate(err, ErrCannotPrepareRequest, errorMessages)
		}
		request.Header.Set("Content-Type", params.ContentType)
	}
	if params.Version != nil {
		request.Header.Set("Version", params.Version.String())
	}
	if params.Token != nil {
		request = jwt.AddToRequest(request, params.Token)
	}
	if params.Accept == "" {
		params.Accept = params.ContentType
	}
	if params.Accept != "" {
		request.Header.Set("Accept", params.Accept)
	}
	return request, nil
}
func ( c * caller ) prepareRequest ( method , urlStr string , params * Parameters ) ( * http . Request , error ) { if params == nil { params = & Parameters { } } var request * http . Request var err error if method == " " || method == " " { request , err = http . NewRequest ( method , urlStr , nil ) if err != nil { return nil , errors . Annotate ( err , ErrCannotPrepareRequest , errorMessages ) } values , err := params . values ( ) if err != nil { return nil , err } request . URL . RawQuery = values . Encode ( ) request . Header . Set ( " " , rest . ContentTypeURLEncoded ) } else { body , err := params . body ( ) if err != nil { return nil , err } request , err = http . NewRequest ( method , urlStr , body ) if err != nil { return nil , errors . Annotate ( err , ErrCannotPrepareRequest , errorMessages ) } request . Header . Set ( " " , params . ContentType ) } if params . Version != nil { request . Header . Set ( " " , params . Version . String ( ) ) } if params . Token != nil { request = jwt . AddToRequest ( request , params . Token ) } if params . Accept == " " { params . Accept = params . ContentType } if params . Accept != " " { request . Header . Set ( " " , params . Accept ) } return request , nil }
prepareRequest prepares the request to perform.
prepareRequest prepares the request to perform .
// These allow only URL encoded. // Here use the body for content.