frostfs-node/pkg/services/object/acl/eacl/v2/xheader.go
Leonard Lyubich 69a69cdbee [#67] object/eacl: Implement eACL validator
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-10-02 19:46:45 +03:00

63 lines
1.1 KiB
Go

package v2
import (
"github.com/nspcc-dev/neofs-api-go/v2/session"
)
type xHeaderSource interface {
GetXHeaders() []*session.XHeader
}
type requestXHeaderSource struct {
req Request
}
type responseXHeaderSource struct {
resp Response
}
func (s *requestXHeaderSource) GetXHeaders() []*session.XHeader {
ln := 0
xHdrs := make([][]*session.XHeader, 0)
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
x := meta.GetXHeaders()
ln += len(x)
xHdrs = append(xHdrs, x)
}
res := make([]*session.XHeader, 0, ln)
for i := range xHdrs {
for j := range xHdrs[i] {
res = append(res, xHdrs[i][j])
}
}
return res
}
func (s *responseXHeaderSource) GetXHeaders() []*session.XHeader {
ln := 0
xHdrs := make([][]*session.XHeader, 0)
for meta := s.resp.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
x := meta.GetXHeaders()
ln += len(x)
xHdrs = append(xHdrs, x)
}
res := make([]*session.XHeader, 0, ln)
for i := range xHdrs {
for j := range xHdrs[i] {
res = append(res, xHdrs[i][j])
}
}
return res
}