flatten get response

This commit is contained in:
Asim Aslam
2021-05-19 14:51:46 +01:00
parent 4981909baf
commit d46644bf4c
3 changed files with 145 additions and 219 deletions

View File

@@ -16,20 +16,15 @@ func (c *Cache) Get(ctx context.Context, req *pb.GetRequest, rsp *pb.GetResponse
return errors.BadRequest("cache.get", "missing key")
}
item := new(pb.Item)
item.Key = req.Key
var value string
if err := cache.Context(ctx).Get(req.Key, &value); err != nil {
return errors.InternalServerError("cache.get", err.Error())
}
rsp.Key = req.Key
// set the value
item.Value = value
// set the item
rsp.Item = item
rsp.Value = value
return nil
}