Proper 404's for objects

This commit is contained in:
Jamie Curnow committed 2023-02-27 17:21:40 +10:00
1 parent 83a9666807
commit 7455accf58
14 files changed
+149 -81

No files matched your search

+10
View File
@@ -81,6 +81,16 @@ func ResultErrorJSON(w http.ResponseWriter, r *http.Request, status int, message
ResultResponseJSON(w, r, status, errorResponse)
}
// NotFound will return a 404 response
func NotFound(w http.ResponseWriter, r *http.Request) {
errorResponse := ErrorResponse{
Code: http.StatusNotFound,
Message: "Not found",
}
ResultResponseJSON(w, r, http.StatusNotFound, errorResponse)
}
// ResultResponseText will write the result as text to the http output
func ResultResponseText(w http.ResponseWriter, r *http.Request, status int, content string) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")