frostfs-node/pkg/services/object/acl/eacl/v2/xheader.go
Evgenii Stratonikov b24589b62d [#1386] eacl/v2: Use raw structs where possible
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2022-05-20 12:04:10 +03:00

65 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
req Request
}
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.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
}