forked from TrueCloudLab/frostfs-api-go
[#168] session: Implement binary/JSON encoders/decoders on TokenBody
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
20bf21e5e4
commit
4e163617d1
4 changed files with 45 additions and 4 deletions
|
@ -44,3 +44,23 @@ func (l *TokenLifetime) UnmarshalJSON(data []byte) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *SessionTokenBody) MarshalJSON() ([]byte, error) {
|
||||
return protojson.MarshalOptions{
|
||||
EmitUnpopulated: true,
|
||||
}.Marshal(
|
||||
SessionTokenBodyToGRPCMessage(t),
|
||||
)
|
||||
}
|
||||
|
||||
func (t *SessionTokenBody) UnmarshalJSON(data []byte) error {
|
||||
msg := new(session.SessionToken_Body)
|
||||
|
||||
if err := protojson.Unmarshal(data, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*t = *SessionTokenBodyFromGRPCMessage(msg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue