package http
import (
)
type MinimumProtocolError struct {
proto string
expectedProtoMajor int
expectedProtoMinor int
}
func ( *MinimumProtocolError) () string {
return fmt.Sprintf("operation requires minimum HTTP protocol of HTTP/%d.%d, but was %s",
.expectedProtoMajor, .expectedProtoMinor, .proto)
}
type RequireMinimumProtocol struct {
ProtoMajor int
ProtoMinor int
}
func ( *middleware.Stack, , int) error {
return .Deserialize.Insert(&RequireMinimumProtocol{
ProtoMajor: ,
ProtoMinor: ,
}, "OperationDeserializer", middleware.Before)
}
func ( *RequireMinimumProtocol) () string {
return "RequireMinimumProtocol"
}
func ( *RequireMinimumProtocol) (
context.Context, middleware.DeserializeInput, middleware.DeserializeHandler,
) (
middleware.DeserializeOutput, middleware.Metadata, error,
) {
, , = .HandleDeserialize(, )
if != nil {
return , ,
}
, := .RawResponse.(*Response)
if ! {
return , , fmt.Errorf("unknown transport type: %T", .RawResponse)
}
if !strings.HasPrefix(.Proto, "HTTP") {
return , , &MinimumProtocolError{
proto: .Proto,
expectedProtoMajor: .ProtoMajor,
expectedProtoMinor: .ProtoMinor,
}
}
if .ProtoMajor < .ProtoMajor || .ProtoMinor < .ProtoMinor {
return , , &MinimumProtocolError{
proto: .Proto,
expectedProtoMajor: .ProtoMajor,
expectedProtoMinor: .ProtoMinor,
}
}
return , ,
}