new packages

This commit is contained in:
Peter Rounce 2023-02-18 14:44:01 +00:00
parent aa5ccaded0
commit 4f4e320999
8 changed files with 83 additions and 70 deletions

19
resp_err/resp_err.go Normal file
View file

@ -0,0 +1,19 @@
package resp_err
import (
"net/http"
)
func Write(w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
jsonData := []byte(`{"status":"ERROR","reason":"bad request"}`)
w.Write(jsonData)
}
func Write_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)
}