package customizations
import (
smithyxml
smithyhttp
)
func ( *middleware.Stack) error {
return .Deserialize.Insert(&processResponseFor200ErrorMiddleware{}, "OperationDeserializer", middleware.After)
}
type processResponseFor200ErrorMiddleware struct{}
func (*processResponseFor200ErrorMiddleware) () string {
return "S3:ProcessResponseFor200Error"
}
func ( *processResponseFor200ErrorMiddleware) (
context.Context, middleware.DeserializeInput, middleware.DeserializeHandler) (
middleware.DeserializeOutput, middleware.Metadata, error,
) {
, , = .HandleDeserialize(, )
if != nil {
return , ,
}
, := .RawResponse.(*smithyhttp.Response)
if ! {
return , , &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", .RawResponse)}
}
if .StatusCode < 200 || .StatusCode >= 300 {
return
}
var bytes.Buffer
:= io.TeeReader(.Body, &)
:= xml.NewDecoder()
, := smithyxml.FetchRootElement()
if == io.EOF {
return , , &smithy.DeserializationError{
Err: fmt.Errorf("received empty response payload"),
}
}
.Body = ioutil.NopCloser(io.MultiReader(&, .Body))
if strings.EqualFold(.Name.Local, "Error") {
.StatusCode = 500
}
return , ,
}