Update IAM access manager plugin demo (#19007)

Now prints the JSON payload for easier debugging.
This commit is contained in:
Aditya Manthramurthy 2024-02-08 09:15:20 -08:00 committed by GitHub
parent e104b183d8
commit a29c66ed74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -21,6 +21,7 @@
package main package main
import ( import (
"bytes"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
@ -58,6 +59,10 @@ func mainHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
var out bytes.Buffer
json.Indent(&out, body, "", " ")
fmt.Printf("Received JSON payload:\n%s\n", out.String())
reqMap := make(map[string]interface{}) reqMap := make(map[string]interface{})
err = json.Unmarshal(body, &reqMap) err = json.Unmarshal(body, &reqMap)
if err != nil { if err != nil {
@ -65,8 +70,6 @@ func mainHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
// fmt.Printf("request: %#v\n", reqMap)
m := reqMap["input"].(map[string]interface{}) m := reqMap["input"].(map[string]interface{})
accountValue := m["account"].(string) accountValue := m["account"].(string)
actionValue := m["action"].(string) actionValue := m["action"].(string)