add vendor data
All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 1m49s
All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 1m49s
This commit is contained in:
73
vendor/github.com/dunglas/httpsfv/item.go
generated
vendored
Normal file
73
vendor/github.com/dunglas/httpsfv/item.go
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
package httpsfv
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Item is a bare value and associated parameters.
|
||||
// See https://httpwg.org/specs/rfc9651.html#item.
|
||||
type Item struct {
|
||||
Value interface{}
|
||||
Params *Params
|
||||
}
|
||||
|
||||
// NewItem returns a new Item.
|
||||
func NewItem(v interface{}) Item {
|
||||
assertBareItem(v)
|
||||
|
||||
return Item{v, NewParams()}
|
||||
}
|
||||
|
||||
func (i Item) member() {
|
||||
}
|
||||
|
||||
// marshalSFV serializes as defined in
|
||||
// https://httpwg.org/specs/rfc9651.html#ser-item.
|
||||
func (i Item) marshalSFV(b *strings.Builder) error {
|
||||
if i.Value == nil {
|
||||
return ErrInvalidBareItem
|
||||
}
|
||||
|
||||
if err := marshalBareItem(b, i.Value); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return i.Params.marshalSFV(b)
|
||||
}
|
||||
|
||||
// UnmarshalItem parses an item as defined in
|
||||
// https://httpwg.org/specs/rfc9651.html#parse-item.
|
||||
func UnmarshalItem(v []string) (Item, error) {
|
||||
s := &scanner{
|
||||
data: strings.Join(v, ","),
|
||||
}
|
||||
|
||||
s.scanWhileSp()
|
||||
|
||||
sfv, err := parseItem(s)
|
||||
if err != nil {
|
||||
return Item{}, err
|
||||
}
|
||||
|
||||
s.scanWhileSp()
|
||||
|
||||
if !s.eof() {
|
||||
return Item{}, &UnmarshalError{off: s.off}
|
||||
}
|
||||
|
||||
return sfv, nil
|
||||
}
|
||||
|
||||
func parseItem(s *scanner) (Item, error) {
|
||||
bi, err := parseBareItem(s)
|
||||
if err != nil {
|
||||
return Item{}, err
|
||||
}
|
||||
|
||||
p, err := parseParams(s)
|
||||
if err != nil {
|
||||
return Item{}, err
|
||||
}
|
||||
|
||||
return Item{bi, p}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user