add descriptive error

This commit is contained in:
Peter Rounce 2022-08-25 21:22:27 +00:00
parent 8d1d686355
commit 44b2f0ba6e
2 changed files with 19 additions and 4 deletions

15
main.go
View file

@ -7,10 +7,17 @@ import (
)
func write_error(w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
jsonData := []byte(`{"status":"ERROR","reason":"bad request"}`)
w.Write(jsonData)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
jsonData := []byte(`{"status":"ERROR","reason":"bad request"}`)
w.Write(jsonData)
}
func write_error_message(w http.ResponseWriter, message string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
jsonData := []byte(`{"status":"ERROR","reason":"` + message + `"}`)
w.Write(jsonData)
}
func main() {