Make caps codec return error through API instead of directly

This commit is contained in:
ionutboangiu
2023-02-14 11:58:56 -05:00
committed by Dan Christian Bogos
parent c7a52d7573
commit 3b0a397cd0
9 changed files with 67 additions and 7 deletions

View File

@@ -164,14 +164,18 @@ type capsBiRPCCodec struct {
// ReadHeader must read a message and populate either the request
// or the response by inspecting the incoming message.
func (c *capsBiRPCCodec) ReadHeader(req *rpc2.Request, resp *rpc2.Response) (err error) {
return c.sc.ReadHeader(req, resp)
if err = c.sc.ReadHeader(req, resp); err != nil || req.Method == utils.EmptyString {
return
}
if err = c.caps.Allocate(); err != nil {
req.Method = utils.SessionSv1CapsError
err = nil
}
return
}
// ReadRequestBody into args argument of handler function.
func (c *capsBiRPCCodec) ReadRequestBody(x interface{}) (err error) {
if err = c.caps.Allocate(); err != nil {
return
}
return c.sc.ReadRequestBody(x)
}