[#168] session: Implement binary/JSON encoders/decoders on RequestVerify

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-13 17:07:49 +03:00 committed by Alex Vanin
parent 8f8e977a3e
commit 986bc1b0ea
4 changed files with 45 additions and 4 deletions

View file

@ -124,3 +124,23 @@ func (r *RequestMetaHeader) UnmarshalJSON(data []byte) error {
return nil
}
func (r *RequestVerificationHeader) MarshalJSON() ([]byte, error) {
return protojson.MarshalOptions{
EmitUnpopulated: true,
}.Marshal(
RequestVerificationHeaderToGRPCMessage(r),
)
}
func (r *RequestVerificationHeader) UnmarshalJSON(data []byte) error {
msg := new(session.RequestVerificationHeader)
if err := protojson.Unmarshal(data, msg); err != nil {
return err
}
*r = *RequestVerificationHeaderFromGRPCMessage(msg)
return nil
}