diff options
author | Matthew Lemon <y@yulqen.org> | 2024-02-10 12:41:09 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-02-10 12:41:09 +0000 |
commit | aa9b88ae875bfa82500e4702583cc40010825e71 (patch) | |
tree | a9ea03e52506348673bf692fa297285a2d208beb | |
parent | c994f479e04ad682e0995abff37af1e3d3749f65 (diff) |
Adds a comment above code to handle "/" route
We only want "/" to match the home route; this comment explains that.
-rw-r--r-- | cmd/web/handlers.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 667c38b..bfe73dd 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -31,6 +31,10 @@ func (app *application) listOrganisation(w http.ResponseWriter, r *http.Request) } func (app *application) home(w http.ResponseWriter, r *http.Request) { + // Check if the current request URL path exactly matches "/". If it doesn't, use + // the http.NotFound() function to send a 404 response to the client. + // Importantly, we then return from the handler. If we don't return the handler + // would keep executing. if r.URL.Path != "/" { app.notFound(w) return |