mirror of
https://github.com/aykhans/dodo.git
synced 2025-09-03 18:03:34 +00:00
🔨 Add 'User-Agent'in 'SetDefaults' function
This commit is contained in:
@@ -73,6 +73,15 @@ func (headers Headers) GetValue(key string) *[]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (headers Headers) Has(key string) bool {
|
||||
for i := range headers {
|
||||
if headers[i].Key == key {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (headers *Headers) UnmarshalJSON(b []byte) error {
|
||||
var data []map[string]any
|
||||
if err := json.Unmarshal(b, &data); err != nil {
|
||||
@@ -137,3 +146,11 @@ func (headers *Headers) Set(value string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (headers *Headers) SetIfNotExists(key string, value string) bool {
|
||||
if headers.Has(key) {
|
||||
return false
|
||||
}
|
||||
*headers = append(*headers, KeyValue[string, []string]{Key: key, Value: []string{value}})
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user