2020-11-16 09:30:46 +00:00
|
|
|
package pkg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
|
|
|
)
|
|
|
|
|
|
|
|
// XHeader represents v2-compatible XHeader.
|
|
|
|
type XHeader session.XHeader
|
|
|
|
|
|
|
|
// NewXHeaderFromV2 wraps v2 XHeader message to XHeader.
|
2021-06-08 18:28:36 +00:00
|
|
|
//
|
|
|
|
// Nil session.XHeader converts to nil.
|
2020-11-16 09:30:46 +00:00
|
|
|
func NewXHeaderFromV2(v *session.XHeader) *XHeader {
|
|
|
|
return (*XHeader)(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewXHeader creates, initializes and returns blank XHeader instance.
|
2021-06-08 18:31:15 +00:00
|
|
|
//
|
|
|
|
// Defaults:
|
|
|
|
// - key: "";
|
|
|
|
// - value: "".
|
2020-11-16 09:30:46 +00:00
|
|
|
func NewXHeader() *XHeader {
|
|
|
|
return NewXHeaderFromV2(new(session.XHeader))
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToV2 converts XHeader to v2 XHeader message.
|
2021-06-08 18:28:36 +00:00
|
|
|
//
|
|
|
|
// Nil XHeader converts to nil.
|
2020-11-16 09:30:46 +00:00
|
|
|
func (x *XHeader) ToV2() *session.XHeader {
|
|
|
|
return (*session.XHeader)(x)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Key returns key to X-Header.
|
|
|
|
func (x *XHeader) Key() string {
|
|
|
|
return (*session.XHeader)(x).
|
|
|
|
GetKey()
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetKey sets key to X-Header.
|
|
|
|
func (x *XHeader) SetKey(k string) {
|
|
|
|
(*session.XHeader)(x).
|
|
|
|
SetKey(k)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Value returns value of X-Header.
|
|
|
|
func (x *XHeader) Value() string {
|
|
|
|
return (*session.XHeader)(x).
|
|
|
|
GetValue()
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetValue sets value of X-Header.
|
|
|
|
func (x *XHeader) SetValue(k string) {
|
|
|
|
(*session.XHeader)(x).
|
|
|
|
SetValue(k)
|
|
|
|
}
|