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