forked from TrueCloudLab/frostfs-api-go
[#168] acl: Implement binary/JSON encoders/decoders on HeaderFilter
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
9bebc1247d
commit
7f42156201
6 changed files with 175 additions and 60 deletions
|
@ -82,3 +82,23 @@ func BearerTokenFromJSON(data []byte) (*BearerToken, error) {
|
|||
|
||||
return BearerTokenFromGRPCMessage(msg), nil
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) MarshalJSON() ([]byte, error) {
|
||||
return protojson.MarshalOptions{
|
||||
EmitUnpopulated: true,
|
||||
}.Marshal(
|
||||
HeaderFilterToGRPCMessage(f),
|
||||
)
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) UnmarshalJSON(data []byte) error {
|
||||
msg := new(acl.EACLRecord_Filter)
|
||||
|
||||
if err := protojson.Unmarshal(data, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*f = *HeaderFilterFromGRPCMessage(msg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue