[#13] services/object: Implement Head handlers
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
3c773cfa67
commit
881f49814a
2 changed files with 25 additions and 4 deletions
|
@ -129,8 +129,17 @@ func (s *executorSvc) Put(ctx context.Context) (object.PutObjectStreamer, error)
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (*executorSvc) Head(context.Context, *object.HeadRequest) (*object.HeadResponse, error) {
|
||||
panic("implement me")
|
||||
func (s *executorSvc) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) {
|
||||
respBody, err := s.exec.Head(ctx, req.GetBody())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not execute Head request")
|
||||
}
|
||||
|
||||
resp := new(object.HeadResponse)
|
||||
resp.SetBody(respBody)
|
||||
resp.SetMetaHeader(s.metaHeader)
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *searchStreamer) Recv() (*object.SearchResponse, error) {
|
||||
|
|
|
@ -17,6 +17,7 @@ type signService struct {
|
|||
getSigService *util.UnarySignService
|
||||
putService object.Service
|
||||
rangeSigService *util.UnarySignService
|
||||
headSigService *util.UnarySignService
|
||||
}
|
||||
|
||||
type searchStreamSigner struct {
|
||||
|
@ -65,6 +66,12 @@ func NewSignService(key *ecdsa.PrivateKey, svc object.Service) object.Service {
|
|||
return svc.GetRange(ctx, req.(*object.GetRangeRequest))
|
||||
},
|
||||
),
|
||||
headSigService: util.NewUnarySignService(
|
||||
key,
|
||||
func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return svc.Head(ctx, req.(*object.HeadRequest))
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,8 +133,13 @@ func (s *signService) Put(ctx context.Context) (object.PutObjectStreamer, error)
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (s *signService) Head(context.Context, *object.HeadRequest) (*object.HeadResponse, error) {
|
||||
panic("implement me")
|
||||
func (s *signService) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) {
|
||||
resp, err := s.headSigService.HandleUnaryRequest(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return resp.(*object.HeadResponse), nil
|
||||
}
|
||||
|
||||
func (s *searchStreamSigner) Recv() (*object.SearchResponse, error) {
|
||||
|
|
Loading…
Reference in a new issue