2021-02-17 16:36:03 +00:00
|
|
|
package session
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
session "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session/grpc"
|
2021-03-12 12:57:23 +00:00
|
|
|
)
|
|
|
|
|
2021-02-17 16:36:03 +00:00
|
|
|
// RequestHeaders represents common part of
|
|
|
|
// all NeoFS requests including headers.
|
|
|
|
type RequestHeaders struct {
|
|
|
|
metaHeader *RequestMetaHeader
|
|
|
|
|
|
|
|
verifyHeader *RequestVerificationHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetMetaHeader returns meta header of the request.
|
|
|
|
func (c *RequestHeaders) GetMetaHeader() *RequestMetaHeader {
|
|
|
|
if c != nil {
|
|
|
|
return c.metaHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMetaHeader sets meta header of the request.
|
|
|
|
func (c *RequestHeaders) SetMetaHeader(v *RequestMetaHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.metaHeader = v
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetVerificationHeader returns verification header of the request.
|
|
|
|
func (c *RequestHeaders) GetVerificationHeader() *RequestVerificationHeader {
|
|
|
|
if c != nil {
|
|
|
|
return c.verifyHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetVerificationHeader sets verification header of the request.
|
|
|
|
func (c *RequestHeaders) SetVerificationHeader(v *RequestVerificationHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.verifyHeader = v
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 12:57:23 +00:00
|
|
|
func (c *RequestHeaders) ToMessage(m interface {
|
|
|
|
SetMetaHeader(*session.RequestMetaHeader)
|
|
|
|
SetVerifyHeader(*session.RequestVerificationHeader)
|
|
|
|
}) {
|
|
|
|
m.SetMetaHeader(c.metaHeader.ToGRPCMessage().(*session.RequestMetaHeader))
|
|
|
|
m.SetVerifyHeader(c.verifyHeader.ToGRPCMessage().(*session.RequestVerificationHeader))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *RequestHeaders) FromMessage(m interface {
|
|
|
|
GetMetaHeader() *session.RequestMetaHeader
|
|
|
|
GetVerifyHeader() *session.RequestVerificationHeader
|
|
|
|
}) error {
|
|
|
|
metaHdr := m.GetMetaHeader()
|
|
|
|
if metaHdr == nil {
|
|
|
|
c.metaHeader = nil
|
|
|
|
} else {
|
|
|
|
if c.metaHeader == nil {
|
|
|
|
c.metaHeader = new(RequestMetaHeader)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := c.metaHeader.FromGRPCMessage(metaHdr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
verifyHdr := m.GetVerifyHeader()
|
|
|
|
if verifyHdr == nil {
|
|
|
|
c.verifyHeader = nil
|
|
|
|
} else {
|
|
|
|
if c.verifyHeader == nil {
|
|
|
|
c.verifyHeader = new(RequestVerificationHeader)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := c.verifyHeader.FromGRPCMessage(verifyHdr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-02-17 16:36:03 +00:00
|
|
|
// ResponseHeaders represents common part of
|
|
|
|
// all NeoFS responses including headers.
|
|
|
|
type ResponseHeaders struct {
|
|
|
|
metaHeader *ResponseMetaHeader
|
|
|
|
|
|
|
|
verifyHeader *ResponseVerificationHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetMetaHeader returns meta header of the response.
|
|
|
|
func (c *ResponseHeaders) GetMetaHeader() *ResponseMetaHeader {
|
|
|
|
if c != nil {
|
|
|
|
return c.metaHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMetaHeader sets meta header of the response.
|
|
|
|
func (c *ResponseHeaders) SetMetaHeader(v *ResponseMetaHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.metaHeader = v
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetVerificationHeader returns verification header of the response.
|
|
|
|
func (c *ResponseHeaders) GetVerificationHeader() *ResponseVerificationHeader {
|
|
|
|
if c != nil {
|
|
|
|
return c.verifyHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetVerificationHeader sets verification header of the response.
|
|
|
|
func (c *ResponseHeaders) SetVerificationHeader(v *ResponseVerificationHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
c.verifyHeader = v
|
2021-02-17 16:36:03 +00:00
|
|
|
}
|
2021-03-12 12:57:23 +00:00
|
|
|
|
|
|
|
func (c *ResponseHeaders) ToMessage(m interface {
|
|
|
|
SetMetaHeader(*session.ResponseMetaHeader)
|
|
|
|
SetVerifyHeader(*session.ResponseVerificationHeader)
|
|
|
|
}) {
|
|
|
|
m.SetMetaHeader(c.metaHeader.ToGRPCMessage().(*session.ResponseMetaHeader))
|
|
|
|
m.SetVerifyHeader(c.verifyHeader.ToGRPCMessage().(*session.ResponseVerificationHeader))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ResponseHeaders) FromMessage(m interface {
|
|
|
|
GetMetaHeader() *session.ResponseMetaHeader
|
|
|
|
GetVerifyHeader() *session.ResponseVerificationHeader
|
|
|
|
}) error {
|
|
|
|
metaHdr := m.GetMetaHeader()
|
|
|
|
if metaHdr == nil {
|
|
|
|
c.metaHeader = nil
|
|
|
|
} else {
|
|
|
|
if c.metaHeader == nil {
|
|
|
|
c.metaHeader = new(ResponseMetaHeader)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := c.metaHeader.FromGRPCMessage(metaHdr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
verifyHdr := m.GetVerifyHeader()
|
|
|
|
if verifyHdr == nil {
|
|
|
|
c.verifyHeader = nil
|
|
|
|
} else {
|
|
|
|
if c.verifyHeader == nil {
|
|
|
|
c.verifyHeader = new(ResponseVerificationHeader)
|
|
|
|
}
|
|
|
|
|
|
|
|
err := c.verifyHeader.FromGRPCMessage(verifyHdr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|