Documentation ¶
Overview ¶
Package httpheader provides HTTP Header related functions.
Index ¶
- type AdaptSpec
- type HTTPHeader
- func (h *HTTPHeader) Adapt(as *AdaptSpec)
- func (h *HTTPHeader) Add(key, value string)
- func (h *HTTPHeader) AddFrom(src *HTTPHeader)
- func (h *HTTPHeader) AddFromStd(src http.Header)
- func (h *HTTPHeader) Copy() *HTTPHeader
- func (h *HTTPHeader) Del(key string)
- func (h *HTTPHeader) Get(key string) string
- func (h *HTTPHeader) GetAll(key string) []string
- func (h *HTTPHeader) Length() int
- func (h *HTTPHeader) Reset(src http.Header)
- func (h *HTTPHeader) Set(key, value string)
- func (h *HTTPHeader) SetFrom(src *HTTPHeader)
- func (h *HTTPHeader) SetFromStd(src http.Header)
- func (h *HTTPHeader) Std() http.Header
- func (h *HTTPHeader) VisitAll(fn func(key, value string))
- type Validator
- type ValidatorSpec
- type ValueValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdaptSpec ¶
type AdaptSpec struct { Del []string `json:"del" jsonschema:"omitempty,uniqueItems=true"` // NOTE: Set and Add allow empty value. Set map[string]string `json:"set" jsonschema:"omitempty"` Add map[string]string `json:"add" jsonschema:"omitempty"` }
AdaptSpec describes rules for adapting.
type HTTPHeader ¶
type HTTPHeader struct {
// contains filtered or unexported fields
}
HTTPHeader is the wrapper of http.Header with more abilities.
func (*HTTPHeader) Adapt ¶
func (h *HTTPHeader) Adapt(as *AdaptSpec)
Adapt adapts HTTPHeader according to AdaptSpec.
func (*HTTPHeader) AddFrom ¶
func (h *HTTPHeader) AddFrom(src *HTTPHeader)
AddFrom adds values from another HTTPHeader.
func (*HTTPHeader) AddFromStd ¶
func (h *HTTPHeader) AddFromStd(src http.Header)
AddFromStd wraps AddFrom by replacing the parameter type *HTTPHeader with standard http.Header.
func (*HTTPHeader) Copy ¶
func (h *HTTPHeader) Copy() *HTTPHeader
Copy copies HTTPHeader to a whole new HTTPHeader.
func (*HTTPHeader) Del ¶
func (h *HTTPHeader) Del(key string)
Del deletes the key value pair by the key.
func (*HTTPHeader) Get ¶
func (h *HTTPHeader) Get(key string) string
Get gets the FIRST value by the key.
func (*HTTPHeader) GetAll ¶
func (h *HTTPHeader) GetAll(key string) []string
GetAll gets all values of the key.
func (*HTTPHeader) Length ¶
func (h *HTTPHeader) Length() int
Length returns the length of the header in serialized format
func (*HTTPHeader) Reset ¶
func (h *HTTPHeader) Reset(src http.Header)
Reset resets internal src http.Header.
func (*HTTPHeader) Set ¶
func (h *HTTPHeader) Set(key, value string)
Set the key value pair of headers.
func (*HTTPHeader) SetFrom ¶
func (h *HTTPHeader) SetFrom(src *HTTPHeader)
SetFrom sets values from another HTTPHeader.
func (*HTTPHeader) SetFromStd ¶
func (h *HTTPHeader) SetFromStd(src http.Header)
SetFromStd wraps Setfrom by replacing the parameter type *HTTPHeader with standard http.Header.
func (*HTTPHeader) Std ¶
func (h *HTTPHeader) Std() http.Header
Std returns internal Header of standard library.
func (*HTTPHeader) VisitAll ¶
func (h *HTTPHeader) VisitAll(fn func(key, value string))
VisitAll call fn with every key value pair.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator is the entity standing for all operations to HTTPHeader.
func NewValidator ¶
func NewValidator(spec *ValidatorSpec) *Validator
NewValidator creates a validator.
func (Validator) Validate ¶
func (v Validator) Validate(h *HTTPHeader) error
Validate validates HTTPHeader by the Validator.
type ValidatorSpec ¶
type ValidatorSpec map[string]*ValueValidator
ValidatorSpec describes Validator
type ValueValidator ¶
type ValueValidator struct { // NOTE: It allows empty value. Values []string `json:"values" jsonschema:"omitempty,uniqueItems=true"` Regexp string `json:"regexp" jsonschema:"omitempty,format=regexp"` // contains filtered or unexported fields }
ValueValidator is the entity to validate value.
func (ValueValidator) Validate ¶
func (vv ValueValidator) Validate() error
Validate validates ValueValidator.