From 295270c0aceb7d91e66310d4a86342e1b46a511d Mon Sep 17 00:00:00 2001 From: Johan Brandhorst Date: Fri, 22 Dec 2017 11:22:36 +0000 Subject: [PATCH] Implement grpc-gateway Delimited interface Implement the Delimited interface for the gogo/protobuf JSONPb marshaller. Fixes #20925 --- pkg/util/protoutil/jsonpb_marshal.go | 5 +++++ pkg/util/protoutil/marshaler.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pkg/util/protoutil/jsonpb_marshal.go b/pkg/util/protoutil/jsonpb_marshal.go index 5c9317720be1..aec642045a75 100644 --- a/pkg/util/protoutil/jsonpb_marshal.go +++ b/pkg/util/protoutil/jsonpb_marshal.go @@ -133,3 +133,8 @@ func (j *JSONPb) NewEncoder(w io.Writer) gwruntime.Encoder { return errors.Errorf("unexpected type %T does not implement %s", v, typeProtoMessage) }) } + +// Delimiter implements gwruntime.Delimited. +func (*JSONPb) Delimiter() []byte { + return []byte("\n") +} diff --git a/pkg/util/protoutil/marshaler.go b/pkg/util/protoutil/marshaler.go index 0f93fba8820f..9317c16f672d 100644 --- a/pkg/util/protoutil/marshaler.go +++ b/pkg/util/protoutil/marshaler.go @@ -101,3 +101,8 @@ func (e *protoEncoder) Encode(v interface{}) error { } return errors.Errorf("unexpected type %T does not implement %s", v, typeProtoMessage) } + +// Delimiter implements gwruntime.Delimited. +func (*ProtoPb) Delimiter() []byte { + return nil +}