Fix a 500 error caused by an interface conversion in Redis (#308)

This commit is contained in:
M. Mert Yıldıran
2021-09-29 14:37:50 +03:00
committed by GitHub
parent 352567c56e
commit 26efaa101d
2 changed files with 8 additions and 8 deletions

View File

@@ -24,27 +24,27 @@ type RedisWrapper struct {
Details interface{} `json:"details"` Details interface{} `json:"details"`
} }
func representGeneric(generic map[string]string) (representation []interface{}) { func representGeneric(generic map[string]interface{}) (representation []interface{}) {
details, _ := json.Marshal([]map[string]string{ details, _ := json.Marshal([]map[string]string{
{ {
"name": "Type", "name": "Type",
"value": generic["type"], "value": generic["type"].(string),
}, },
{ {
"name": "Command", "name": "Command",
"value": generic["command"], "value": generic["command"].(string),
}, },
{ {
"name": "Key", "name": "Key",
"value": generic["key"], "value": generic["key"].(string),
}, },
{ {
"name": "Value", "name": "Value",
"value": generic["value"], "value": generic["value"].(string),
}, },
{ {
"name": "Keyword", "name": "Keyword",
"value": generic["keyword"], "value": generic["keyword"].(string),
}, },
}) })
representation = append(representation, map[string]string{ representation = append(representation, map[string]string{

View File

@@ -141,8 +141,8 @@ func (d dissecting) Represent(entry *api.MizuEntry) (p api.Protocol, object []by
representation := make(map[string]interface{}, 0) representation := make(map[string]interface{}, 0)
request := root["request"].(map[string]interface{})["payload"].(map[string]interface{}) request := root["request"].(map[string]interface{})["payload"].(map[string]interface{})
response := root["response"].(map[string]interface{})["payload"].(map[string]interface{}) response := root["response"].(map[string]interface{})["payload"].(map[string]interface{})
reqDetails := request["details"].(map[string]string) reqDetails := request["details"].(map[string]interface{})
resDetails := response["details"].(map[string]string) resDetails := response["details"].(map[string]interface{})
repRequest := representGeneric(reqDetails) repRequest := representGeneric(reqDetails)
repResponse := representGeneric(resDetails) repResponse := representGeneric(resDetails)
representation["request"] = repRequest representation["request"] = repRequest