Revert "Version bump to etcd v3.2.11, grpc v1.7.5"

This commit is contained in:
Wojciech Tyczynski
2017-12-19 15:25:06 +01:00
committed by GitHub
parent 0d42e742da
commit 4e8526dc6b
381 changed files with 9452 additions and 37110 deletions

View File

@@ -6,9 +6,9 @@ import (
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/status"
)
// HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status.
@@ -64,7 +64,7 @@ var (
type errorBody struct {
Error string `protobuf:"bytes,1,name=error" json:"error"`
Code int32 `protobuf:"varint,2,name=code" json:"code"`
Code int `protobuf:"bytes,2,name=code" json:"code"`
}
//Make this also conform to proto.Message for builtin JSONPb Marshaler
@@ -78,20 +78,14 @@ func (*errorBody) ProtoMessage() {}
//
// The response body returned by this function is a JSON object,
// which contains a member whose key is "error" and whose value is err.Error().
func DefaultHTTPError(ctx context.Context, mux *ServeMux, marshaler Marshaler, w http.ResponseWriter, _ *http.Request, err error) {
func DefaultHTTPError(ctx context.Context, marshaler Marshaler, w http.ResponseWriter, _ *http.Request, err error) {
const fallback = `{"error": "failed to marshal error message"}`
w.Header().Del("Trailer")
w.Header().Set("Content-Type", marshaler.ContentType())
s, ok := status.FromError(err)
if !ok {
s = status.New(codes.Unknown, err.Error())
}
body := &errorBody{
Error: s.Message(),
Code: int32(s.Code()),
Error: grpc.ErrorDesc(err),
Code: int(grpc.Code(err)),
}
buf, merr := marshaler.Marshal(body)
@@ -109,9 +103,9 @@ func DefaultHTTPError(ctx context.Context, mux *ServeMux, marshaler Marshaler, w
grpclog.Printf("Failed to extract ServerMetadata from context")
}
handleForwardResponseServerMetadata(w, mux, md)
handleForwardResponseServerMetadata(w, md)
handleForwardResponseTrailerHeader(w, md)
st := HTTPStatusFromCode(s.Code())
st := HTTPStatusFromCode(grpc.Code(err))
w.WriteHeader(st)
if _, err := w.Write(buf); err != nil {
grpclog.Printf("Failed to write response: %v", err)