From f9ed43b5b94dfdc7ccf0e48bb1dbec8f24f2d206 Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Tue, 12 Jan 2021 12:22:04 +0100 Subject: [PATCH] Revert "server: remove support for binary protobuf payloads in the HTTP endpoints" This reverts commit 5bcd86f3787783c65620c6353e709f483486ee04. Release note: None --- pkg/server/server.go | 3 +++ pkg/util/httputil/http.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/pkg/server/server.go b/pkg/server/server.go index e515f9440109..fbef9d4a3e73 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -1182,10 +1182,13 @@ func (s *Server) Start(ctx context.Context) error { EmitDefaults: true, Indent: " ", } + protopb := new(protoutil.ProtoPb) gwMux := gwruntime.NewServeMux( gwruntime.WithMarshalerOption(gwruntime.MIMEWildcard, jsonpb), gwruntime.WithMarshalerOption(httputil.JSONContentType, jsonpb), gwruntime.WithMarshalerOption(httputil.AltJSONContentType, jsonpb), + gwruntime.WithMarshalerOption(httputil.ProtoContentType, protopb), + gwruntime.WithMarshalerOption(httputil.AltProtoContentType, protopb), gwruntime.WithOutgoingHeaderMatcher(authenticationHeaderMatcher), gwruntime.WithMetadata(forwardAuthenticationMetadata), ) diff --git a/pkg/util/httputil/http.go b/pkg/util/httputil/http.go index fcd9f7a94387..fd02d3030b71 100644 --- a/pkg/util/httputil/http.go +++ b/pkg/util/httputil/http.go @@ -34,6 +34,10 @@ const ( JSONContentType = "application/json" // AltJSONContentType is the alternate JSON content type. AltJSONContentType = "application/x-json" + // ProtoContentType is the protobuf content type. + ProtoContentType = "application/x-protobuf" + // AltProtoContentType is the alternate protobuf content type. + AltProtoContentType = "application/x-google-protobuf" // PlaintextContentType is the plaintext content type. PlaintextContentType = "text/plain" // GzipEncoding is the gzip encoding.