Skip to content

Commit

Permalink
update and getall methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar committed Jun 28, 2023
1 parent a8cdf84 commit da6ed76
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions url/orderedparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ func (o *OrderedParams) IsEmpty() bool {
return o.om.IsEmpty()
}

// Update is similar to Set but it takes value as slice (similar to internal implementation of url.Values)
func (o *OrderedParams) Update(key string, value []string) {
o.om.Set(key, value)
}

// Iterate iterates over the OrderedParams
func (o *OrderedParams) Iterate(f func(key string, value []string) bool) {
o.om.Iterate(func(key string, value []string) bool {
Expand Down Expand Up @@ -59,6 +64,15 @@ func (o *OrderedParams) Get(key string) string {
return val[0]
}

// GetAll returns all values of given key or returns empty slice if key doesn't exist
func (o *OrderedParams) GetAll(key string) []string {
val, ok := o.om.Get(key)
if !ok || len(val) == 0 {
return []string{}
}
return val
}

// Has returns if given key exists
func (o *OrderedParams) Has(key string) bool {
return o.om.Has(key)
Expand Down

0 comments on commit da6ed76

Please sign in to comment.