Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

41
pkg/utils/map_helper.go Normal file
View File

@@ -0,0 +1,41 @@
package utils
type MapHelper struct {
}
func (h *MapHelper) GetString(m map[string]interface{}, key string, defaultVal string) string {
val, ok := m[key]
if !ok {
return defaultVal
}
result, ok := val.(string)
if !ok {
return defaultVal
}
return result
}
func (h *MapHelper) GetData(m map[string]interface{}, key string) []byte {
val, ok := m[key]
if !ok {
return nil
}
// TODO maybe there is a better way to serialize and deserialize JSON RPC binary data
// Go by default does not convert []uint JSON into []byte. Thus the code below
vals, ok := val.([]interface{})
if !ok {
return nil
}
var x int64
result := make([]byte, len(vals))
for i, value := range vals {
x = int64(value.(float64))
result[i] = byte(x)
}
return result
}