Created
May 4, 2018 11:23
-
-
Save adigunhammedolalekan/651a63f3e6193affcfc0b43d1387fb7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils | |
import ( | |
"encoding/json" | |
"net/http" | |
) | |
func Message(status bool, message string) (map[string]interface{}) { | |
return map[string]interface{} {"status" : status, "message" : message} | |
} | |
func Respond(w http.ResponseWriter, data map[string] interface{}) { | |
w.Header().Add("Content-Type", "application/json") | |
json.NewEncoder(w).Encode(data) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
data
variable in theRespond()
function shouldn't have a space betweenmap[string]
andinterface{}
. Just something that caught my eye while reading your Medium article. Thanks for putting this content out there!