From 1cc7983c4e9168f9b736700f56f05ad126cefbac Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 22 Oct 2020 14:02:40 +0300 Subject: [PATCH] [#83] services/util: Add meta header methods to ResponseMessage Signed-off-by: Leonard Lyubich --- pkg/services/util/sign.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/services/util/sign.go b/pkg/services/util/sign.go index 6264e4f77..83ac05944 100644 --- a/pkg/services/util/sign.go +++ b/pkg/services/util/sign.go @@ -4,12 +4,16 @@ import ( "context" "crypto/ecdsa" + "github.com/nspcc-dev/neofs-api-go/v2/session" "github.com/nspcc-dev/neofs-api-go/v2/signature" "github.com/pkg/errors" ) // ResponseMessage is an interface of NeoFS response message. -type ResponseMessage interface{} +type ResponseMessage interface { + GetMetaHeader() *session.ResponseMetaHeader + SetMetaHeader(*session.ResponseMetaHeader) +} type UnaryHandler func(context.Context, interface{}) (ResponseMessage, error) @@ -54,7 +58,7 @@ func (s *RequestMessageStreamer) Send(req interface{}) error { return s.send(req) } -func (s *RequestMessageStreamer) CloseAndRecv() (interface{}, error) { +func (s *RequestMessageStreamer) CloseAndRecv() (ResponseMessage, error) { resp, err := s.close() if err != nil { return nil, errors.Wrap(err, "could not close stream and receive response") @@ -75,7 +79,7 @@ func (s *SignService) CreateRequestStreamer(sender RequestMessageWriter, closer } } -func (s *ResponseMessageStreamer) Recv() (interface{}, error) { +func (s *ResponseMessageStreamer) Recv() (ResponseMessage, error) { m, err := s.recv() if err != nil { return nil, errors.Wrap(err, "could not receive response message for signing") @@ -105,7 +109,7 @@ func (s *SignService) HandleServerStreamRequest(ctx context.Context, req interfa }, nil } -func (s *SignService) HandleUnaryRequest(ctx context.Context, req interface{}, handler UnaryHandler) (interface{}, error) { +func (s *SignService) HandleUnaryRequest(ctx context.Context, req interface{}, handler UnaryHandler) (ResponseMessage, error) { // verify request signatures if err := signature.VerifyServiceMessage(req); err != nil { return nil, errors.Wrap(err, "could not verify request")