1
0
Fork 0
mirror of https://github.com/Luzifer/mondash.git synced 2024-11-10 08:30:02 +00:00
mondash/vendor/github.com/aws/aws-sdk-go/private/protocol/query/build.go

37 lines
1.2 KiB
Go
Raw Normal View History

// Package query provides serialization of AWS query requests, and responses.
2016-01-23 12:07:07 +00:00
package query
//go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/input/query.json build_test.go
2016-01-23 12:07:07 +00:00
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"
"github.com/aws/aws-sdk-go/private/protocol/query/queryutil"
2016-01-23 12:07:07 +00:00
)
// BuildHandler is a named request handler for building query protocol requests
var BuildHandler = request.NamedHandler{Name: "awssdk.query.Build", Fn: Build}
2016-01-23 12:07:07 +00:00
// 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.ClientInfo.APIVersion},
2016-01-23 12:07:07 +00:00
}
if err := queryutil.Parse(body, r.Params, false); err != nil {
r.Error = awserr.New(request.ErrCodeSerialization, "failed encoding Query request", err)
2016-01-23 12:07:07 +00:00
return
}
if !r.IsPresigned() {
2016-01-23 12:07:07 +00:00
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()
}
}