Proper 404's for objects

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

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")