[#337] client: Add option to specify callback of response information

There is a need to analyze some response information in API client.

Define `ResponseMetaInfo` structure of response information. Add
`WithResponseInfoHandler` client option which allows to set the response
info callback. The callback is called right after any response is received.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-09-27 14:42:16 +03:00 committed by Alex Vanin
parent 3844a3ac74
commit da89c2b71f
8 changed files with 139 additions and 0 deletions

View file

@ -77,6 +77,11 @@ func (c *clientImpl) AnnounceLocalTrust(ctx context.Context, prm AnnounceLocalTr
return nil, err
}
// handle response meta info
if err := c.handleResponseInfoV2(callOptions, resp); err != nil {
return nil, err
}
err = v2signature.VerifyServiceMessage(resp)
if err != nil {
return nil, fmt.Errorf("can't verify response message: %w", err)
@ -152,6 +157,11 @@ func (c *clientImpl) AnnounceIntermediateTrust(ctx context.Context, prm Announce
return nil, err
}
// handle response meta info
if err := c.handleResponseInfoV2(callOptions, resp); err != nil {
return nil, err
}
err = v2signature.VerifyServiceMessage(resp)
if err != nil {
return nil, fmt.Errorf("can't verify response message: %w", err)