]>
Commit | Line | Data |
---|---|---|
bae9f6d2 JC |
1 | package query |
2 | ||
3 | //go:generate go run -tags codegen ../../../models/protocol_tests/generate.go ../../../models/protocol_tests/output/query.json unmarshal_test.go | |
4 | ||
5 | import ( | |
6 | "encoding/xml" | |
7 | ||
8 | "github.com/aws/aws-sdk-go/aws/awserr" | |
9 | "github.com/aws/aws-sdk-go/aws/request" | |
10 | "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" | |
11 | ) | |
12 | ||
13 | // UnmarshalHandler is a named request handler for unmarshaling query protocol requests | |
14 | var UnmarshalHandler = request.NamedHandler{Name: "awssdk.query.Unmarshal", Fn: Unmarshal} | |
15 | ||
16 | // UnmarshalMetaHandler is a named request handler for unmarshaling query protocol request metadata | |
17 | var UnmarshalMetaHandler = request.NamedHandler{Name: "awssdk.query.UnmarshalMeta", Fn: UnmarshalMeta} | |
18 | ||
19 | // Unmarshal unmarshals a response for an AWS Query service. | |
20 | func Unmarshal(r *request.Request) { | |
21 | defer r.HTTPResponse.Body.Close() | |
22 | if r.DataFilled() { | |
23 | decoder := xml.NewDecoder(r.HTTPResponse.Body) | |
24 | err := xmlutil.UnmarshalXML(r.Data, decoder, r.Operation.Name+"Result") | |
25 | if err != nil { | |
26 | r.Error = awserr.New("SerializationError", "failed decoding Query response", err) | |
27 | return | |
28 | } | |
29 | } | |
30 | } | |
31 | ||
32 | // UnmarshalMeta unmarshals header response values for an AWS Query service. | |
33 | func UnmarshalMeta(r *request.Request) { | |
34 | r.RequestID = r.HTTPResponse.Header.Get("X-Amzn-Requestid") | |
35 | } |