Airat Arifullin
9b13a18aac
* Update version within go.mod; * Fix deprecated frostfs-api-go/v2 package and use frostfs-sdk-go/api instead. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
69 lines
1.3 KiB
Go
69 lines
1.3 KiB
Go
package v2
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session"
|
|
eaclSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/eacl"
|
|
)
|
|
|
|
type XHeaderSource interface {
|
|
GetXHeaders() []eaclSDK.Header
|
|
}
|
|
|
|
type requestXHeaderSource struct {
|
|
req Request
|
|
}
|
|
|
|
func NewRequestXHeaderSource(req Request) XHeaderSource {
|
|
return requestXHeaderSource{req: req}
|
|
}
|
|
|
|
type responseXHeaderSource struct {
|
|
resp Response
|
|
|
|
req Request
|
|
}
|
|
|
|
func NewResponseXHeaderSource(resp Response, req Request) XHeaderSource {
|
|
return responseXHeaderSource{resp: resp, req: req}
|
|
}
|
|
|
|
func (s requestXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
|
ln := 0
|
|
|
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
|
ln += len(meta.GetXHeaders())
|
|
}
|
|
|
|
res := make([]eaclSDK.Header, 0, ln)
|
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
|
x := meta.GetXHeaders()
|
|
for i := range x {
|
|
res = append(res, (xHeader)(x[i]))
|
|
}
|
|
}
|
|
|
|
return res
|
|
}
|
|
|
|
func (s responseXHeaderSource) GetXHeaders() []eaclSDK.Header {
|
|
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([]eaclSDK.Header, 0, ln)
|
|
|
|
for i := range xHdrs {
|
|
for j := range xHdrs[i] {
|
|
res = append(res, xHeader(xHdrs[i][j]))
|
|
}
|
|
}
|
|
|
|
return res
|
|
}
|