add descriptive error
This commit is contained in:
parent
8d1d686355
commit
44b2f0ba6e
2 changed files with 19 additions and 4 deletions
15
main.go
15
main.go
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue