Skip to content

Instantly share code, notes, and snippets.

@adigunhammedolalekan
Created May 4, 2018 11:23
Show Gist options
  • Save adigunhammedolalekan/651a63f3e6193affcfc0b43d1387fb7b to your computer and use it in GitHub Desktop.
Save adigunhammedolalekan/651a63f3e6193affcfc0b43d1387fb7b to your computer and use it in GitHub Desktop.
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)
}
@TheHackerDev
Copy link

The data variable in the Respond() function shouldn't have a space between map[string] and interface{}. Just something that caught my eye while reading your Medium article. Thanks for putting this content out there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment