THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Compare commits

...
3 Commits
Author SHA1 Message Date
peze 21389214ea fix the toMap when input is basic map 2025-04-07 17:23:36 +08:00
peze c2e107f1af fix default condition 2025-04-01 19:14:52 +08:00
peze 5ff9708f43 add retry options config 2025-03-31 16:36:54 +08:00
2 changed files with 84 additions and 6 deletions
+30 -5
View File
@@ -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
}
}
}
}
Internal Server Error - Gitea: Git with a cup of tea
500 Internal Server Error

Gitea Version: 1.28.0+dev-211-ga30d865b78