Skip to content

Commit

Permalink
add map to string function to json function
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Dec 6, 2018
1 parent 6a068a7 commit 7a710b9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion get_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ func GetCredentials(w http.ResponseWriter, r *http.Request) {
},
Flash: flash,
}
tmpl := template.Must(template.ParseFiles("templates/getcredentials/json.html"))
tf := template.FuncMap{
"MapToString": MapToString,
}
tmpl := template.Must(template.New("json.html").Funcs(tf).ParseFiles("templates/getcredentials/json.html"))
tmpl.ExecuteTemplate(w, "base", data3)
return
default:
Expand All @@ -251,3 +254,8 @@ func GetCredentials(w http.ResponseWriter, r *http.Request) {
RedirectHome(w, r)
return
}

func MapToString(mapVal map[string]interface{}) string {
retBytes, _ := json.Marshal(mapVal)
return string(retBytes)
}

0 comments on commit 7a710b9

Please sign in to comment.