mirror of
https://github.com/usual2970/certimate.git
synced 2025-08-06 09:21:46 +00:00
feat: support configuring method and headers in webhook
This commit is contained in:
@@ -199,6 +199,28 @@ func GetOrDefaultBool(dict map[string]any, key string, defaultValue bool) bool {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
// 以 `map[string]V` 形式从字典中获取指定键的值。
|
||||
//
|
||||
// 入参:
|
||||
// - dict: 字典。
|
||||
// - key: 键。
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的 `map[string]V` 对象。
|
||||
func GetKVMap[V any](dict map[string]any, key string) map[string]V {
|
||||
if dict == nil {
|
||||
return make(map[string]V)
|
||||
}
|
||||
|
||||
if val, ok := dict[key]; ok {
|
||||
if result, ok := val.(map[string]V); ok {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
return make(map[string]V)
|
||||
}
|
||||
|
||||
// 以 `map[string]any` 形式从字典中获取指定键的值。
|
||||
//
|
||||
// 入参:
|
||||
@@ -207,16 +229,6 @@ func GetOrDefaultBool(dict map[string]any, key string, defaultValue bool) bool {
|
||||
//
|
||||
// 出参:
|
||||
// - 字典中键对应的 `map[string]any` 对象。
|
||||
func GetMap(dict map[string]any, key string) map[string]any {
|
||||
if dict == nil {
|
||||
return make(map[string]any)
|
||||
}
|
||||
|
||||
if val, ok := dict[key]; ok {
|
||||
if result, ok := val.(map[string]any); ok {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
return make(map[string]any)
|
||||
func GetKVMapAny(dict map[string]any, key string) map[string]any {
|
||||
return GetKVMap[any](dict, key)
|
||||
}
|
||||
|
Reference in New Issue
Block a user