summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEthel Morgan <eth@ethulhu.co.uk>2020-07-07 16:09:32 +0100
committerEthel Morgan <eth@ethulhu.co.uk>2020-07-07 16:09:32 +0100
commit977df56847fb57ca128df82614798b3301d3dfd6 (patch)
treec317ea7817c38fb3ab3491f423580845ed79a241
parent8e97a7dbf08d8930a440daa49e71d73822bde205 (diff)
add NotFound and NotImplemented http.HandlerFuncsv0.0.2
Diffstat (limited to '')
-rw-r--r--handlers.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/handlers.go b/handlers.go
new file mode 100644
index 0000000..c32fdbd
--- /dev/null
+++ b/handlers.go
@@ -0,0 +1,20 @@
+// SPDX-FileCopyrightText: 2020 Ethel Morgan
+//
+// SPDX-License-Identifier: MIT
+package httputil
+
+import (
+ "fmt"
+ "net/http"
+)
+
+// NotFound is an HTTP NotFound handler that returns an informative message.
+func NotFound(w http.ResponseWriter, r *http.Request) {
+ msg := fmt.Sprintf("not found: %v %v %v", r.Method, r.URL, r.Form)
+ http.Error(w, msg, http.StatusNotFound)
+}
+
+// NotImplemented is an HTTP handler for as-yet unimplemented routes.
+func NotImplemented(w http.ResponseWriter, r *http.Request) {
+ http.Error(w, "not implemented", http.StatusNotImplemented)
+}