1
0
Fork 0
mirror of https://github.com/Luzifer/mondash.git synced 2024-12-25 05:21:18 +00:00
mondash/vendor/github.com/aws/aws-sdk-go/internal/protocol/query/build.go

34 lines
1 KiB
Go
Raw Normal View History

2016-01-23 12:07:07 +00:00
// Package query provides serialisation of AWS query requests, and responses.
package query
//go:generate go run ../../fixtures/protocol/generate.go ../../fixtures/protocol/input/query.json build_test.go
import (
"net/url"
"github.com/aws/aws-sdk-go/aws/awserr"
2016-03-27 18:46:08 +00:00
"github.com/aws/aws-sdk-go/aws/request"
2016-01-23 12:07:07 +00:00
"github.com/aws/aws-sdk-go/internal/protocol/query/queryutil"
)
// Build builds a request for an AWS Query service.
2016-03-27 18:46:08 +00:00
func Build(r *request.Request) {
2016-01-23 12:07:07 +00:00
body := url.Values{
"Action": {r.Operation.Name},
"Version": {r.Service.APIVersion},
}
if err := queryutil.Parse(body, r.Params, false); err != nil {
r.Error = awserr.New("SerializationError", "failed encoding Query request", err)
return
}
if r.ExpireTime == 0 {
r.HTTPRequest.Method = "POST"
r.HTTPRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
r.SetBufferBody([]byte(body.Encode()))
} else { // This is a pre-signed request
r.HTTPRequest.Method = "GET"
r.HTTPRequest.URL.RawQuery = body.Encode()
}
}