Skip to content

Instantly share code, notes, and snippets.

@parzibyte

parzibyte/helpers.go Secret

Created Oct 12, 2020
Embed
What would you like to do?
// Helper functions for respond with 200 or 500 code
func respondWithError(err error, w http.ResponseWriter) {
w.WriteHeader(http.StatusInternalServerError)
json.NewEncoder(w).Encode(err.Error())
}
func respondWithSuccess(data interface{}, w http.ResponseWriter) {
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment