summaryrefslogtreecommitdiffstats
path: root/cmd/web/helpers.go
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-02-10 19:22:56 +0000
committerMatthew Lemon <y@yulqen.org>2024-02-10 19:22:56 +0000
commit58967839c646c717b5345f3a3d2924be5c6d5a4b (patch)
tree3c537852823fb90c374eae385e660b18e05a2ced /cmd/web/helpers.go
parent030806353ca9b329bfb0102ebc10518b641511ee (diff)
Adds the Get handler for organisation model and fixes
Also fixes the NotAuthorised response I was mistakenly getting when it should have been a 404.
Diffstat (limited to 'cmd/web/helpers.go')
-rw-r--r--cmd/web/helpers.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/cmd/web/helpers.go b/cmd/web/helpers.go
index ea09979..5f7e4d3 100644
--- a/cmd/web/helpers.go
+++ b/cmd/web/helpers.go
@@ -1,9 +1,9 @@
package main
import (
- "log"
- "runtime/debug"
+ "log"
"net/http"
+ "runtime/debug"
)
func (app *application) serverError(w http.ResponseWriter, r *http.Request, err error) {
@@ -22,5 +22,10 @@ func (app *application) serverError(w http.ResponseWriter, r *http.Request, err
// to the user. We'll use this later in the book to send responses like 400 "Bad
// Request" when there's a problem with the request that the user sent.
func (app *application) clientError(w http.ResponseWriter, status int) {
- http.Error(w, http.StatusText(status), status)
+ http.Error(w, http.StatusText(status), status)
+}
+
+// notFound helper is a convenience wrapper around clientError which sends a 404 Not Found response
+func (app *application) notFound(w http.ResponseWriter) {
+ app.clientError(w, http.StatusNotFound)
}