Esempio n. 1
0
File: iam.go Progetto: dmp42/goamz
func (iam *IAM) postQuery(params map[string]string, resp interface{}) error {
	endpoint, err := url.Parse(iam.IAMEndpoint)
	if err != nil {
		return err
	}
	params["Version"] = "2010-05-08"
	params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
	signer, err := aws.NewV2Signer(iam.Auth, aws.ServiceInfo{Endpoint: iam.Region.IAMEndpoint, Signer: aws.V2Signature})
	if err != nil {
		return err
	}
	signer.Sign("POST", "/", params)
	encoded := multimap(params).Encode()
	body := strings.NewReader(encoded)
	req, err := http.NewRequest("POST", endpoint.String(), body)
	if err != nil {
		return err
	}
	req.Header.Set("Host", endpoint.Host)
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	req.Header.Set("Content-Length", strconv.Itoa(len(encoded)))
	r, err := http.DefaultClient.Do(req)
	if err != nil {
		return err
	}
	defer r.Body.Close()
	if r.StatusCode > 200 {
		return buildError(r)
	}
	return xml.NewDecoder(r.Body).Decode(resp)
}
Esempio n. 2
0
File: elb.go Progetto: docker/goamz
func (elb *ELB) query(params map[string]string, resp interface{}) error {
	params["Version"] = "2012-06-01"
	params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
	endpoint, err := url.Parse(elb.Region.ELBEndpoint)
	if err != nil {
		return err
	}
	if endpoint.Path == "" {
		endpoint.Path = "/"
	}
	signer, err := aws.NewV2Signer(elb.Auth, aws.ServiceInfo{Endpoint: elb.Region.ELBEndpoint, Signer: 2})
	if err != nil {
		return err
	}
	signer.Sign("GET", endpoint.Path, params)
	endpoint.RawQuery = multimap(params).Encode()

	r, err := http.Get(endpoint.String())
	if err != nil {
		return err
	}
	defer r.Body.Close()
	if r.StatusCode != 200 {
		return buildError(r)
	}
	return xml.NewDecoder(r.Body).Decode(resp)
}
Esempio n. 3
0
File: iam.go Progetto: dmp42/goamz
func (iam *IAM) query(params map[string]string, resp interface{}) error {
	params["Version"] = "2010-05-08"
	params["Timestamp"] = time.Now().In(time.UTC).Format(time.RFC3339)
	endpoint, err := url.Parse(iam.IAMEndpoint)
	if err != nil {
		return err
	}
	signer, err := aws.NewV2Signer(iam.Auth, aws.ServiceInfo{Endpoint: iam.Region.IAMEndpoint, Signer: aws.V2Signature})
	if err != nil {
		return err
	}
	signer.Sign("GET", "/", params)
	endpoint.RawQuery = multimap(params).Encode()
	r, err := http.Get(endpoint.String())
	if err != nil {
		return err
	}
	defer r.Body.Close()
	if r.StatusCode > 200 {
		return buildError(r)
	}
	return xml.NewDecoder(r.Body).Decode(resp)
}