Documentation ¶
Index ¶
- type Pair
- type Storage
- func (s *Storage) Add(key, value string) *Storage
- func (s *Storage) Clear()
- func (s *Storage) Clone() *Storage
- func (s *Storage) Get(key string) (string, bool)
- func (s *Storage) Has(key string) bool
- func (s *Storage) Iter() iter.Iterator[Pair]
- func (s *Storage) Keys() []string
- func (s *Storage) Unwrap() []Pair
- func (s *Storage) Value(key string) string
- func (s *Storage) ValueOr(key, or string) string
- func (s *Storage) Values(key string) (values []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is a generic structure for storing pairs of string-string. It is used across the whole database. For example, it is primarily used for request headers, however used as well as a storage for URI query, dynamic routing parameters, etc.
func NewFromMap ¶
NewFromMap returns a new instance with already inserted values from given map. Note: as maps are unordered, resulting underlying structure will also contain unordered pairs
func NewPreAlloc ¶
NewPreAlloc returns an instance of Storage with pre-allocated underlying storage
func (*Storage) Clear ¶
func (s *Storage) Clear()
Clear all the entries. However, all the allocated space won't be freed
func (*Storage) Clone ¶
Clone creates a deep copy, which may be used later or stored somewhere safely. However, it comes at cost of multiple allocations
func (*Storage) Get ¶
Get returns a value corresponding to the key and a bool, indicating whether the key exists. In case it doesn't, empty string will be returned either
func (*Storage) Keys ¶
Keys returns all unique presented keys.
WARNING: calling it twice will override values, returned by the first call. Consider copying the returned slice for safe use
func (*Storage) Unwrap ¶
Unwrap reveals underlying data structure. Try to avoid the method if possible, as changing the signature may not affect a major version
func (*Storage) Value ¶
Value returns the first value, corresponding to the key. Otherwise, empty string is returned