Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21389214ea | ||
|
|
c2e107f1af | ||
|
|
5ff9708f43 |
+30
-5
@@ -150,6 +150,9 @@ func NewRuntimeObject(runtime map[string]interface{}) *RuntimeObject {
|
||||
if runtime["httpClient"] != nil {
|
||||
runtimeObject.HttpClient = runtime["httpClient"].(HttpClient)
|
||||
}
|
||||
if runtime["retryOptions"] != nil {
|
||||
runtimeObject.RetryOptions = runtime["retryOptions"].(*RetryOptions)
|
||||
}
|
||||
return runtimeObject
|
||||
}
|
||||
|
||||
@@ -639,8 +642,23 @@ func isNil(a interface{}) bool {
|
||||
return vi.IsNil()
|
||||
}
|
||||
|
||||
func isNilOrZero(value interface{}) bool {
|
||||
if value == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
v := reflect.ValueOf(value)
|
||||
switch v.Kind() {
|
||||
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Slice:
|
||||
return v.IsNil()
|
||||
default:
|
||||
// Check for zero value
|
||||
return reflect.DeepEqual(value, reflect.Zero(v.Type()).Interface())
|
||||
}
|
||||
}
|
||||
|
||||
func Default(inputValue interface{}, defaultValue interface{}) (_result interface{}) {
|
||||
if IsNil(inputValue) {
|
||||
if isNilOrZero(inputValue) {
|
||||
_result = defaultValue
|
||||
return _result
|
||||
}
|
||||
@@ -711,10 +729,17 @@ func ToMap(args ...interface{}) map[string]interface{} {
|
||||
}
|
||||
default:
|
||||
val := reflect.ValueOf(obj)
|
||||
res := structToMap(val)
|
||||
for key, value := range res {
|
||||
if value != nil {
|
||||
finalArg[key] = value
|
||||
if val.Kind().String() == "map" {
|
||||
tmp := val.MapKeys()
|
||||
for _, key := range tmp {
|
||||
finalArg[key.String()] = val.MapIndex(key).Interface()
|
||||
}
|
||||
} else {
|
||||
res := structToMap(val)
|
||||
for key, value := range res {
|
||||
if value != nil {
|
||||
finalArg[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
500 Internal Server Error
Gitea Version: 1.28.0+dev-211-ga30d865b78 | ||||