2020-10-22 11:04:46 +00:00
|
|
|
package response
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
2020-10-22 11:04:46 +00:00
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util"
|
2020-10-22 11:04:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// HandleUnaryRequest call passes request to handler, sets response meta header values and returns it.
|
2023-02-21 11:42:45 +00:00
|
|
|
func (s *Service) HandleUnaryRequest(ctx context.Context, req any, handler util.UnaryHandler) (util.ResponseMessage, error) {
|
2020-10-22 11:04:46 +00:00
|
|
|
// process request
|
|
|
|
resp, err := handler(ctx, req)
|
|
|
|
if err != nil {
|
2021-05-18 08:12:51 +00:00
|
|
|
return nil, fmt.Errorf("could not handle request: %w", err)
|
2020-10-22 11:04:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setMeta(resp, s.cfg)
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
}
|