summaryrefslogtreecommitdiff
path: root/handlers.go
blob: 099cb18db5c119a1bb9b5cb2cd5ff4b494c7729b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// SPDX-FileCopyrightText: 2020 Ethel Morgan
//
// SPDX-License-Identifier: MIT
package httputil

import (
	"fmt"
	"net/http"
)

var (
	// NotFoundHandler is a convenience to reduce boilerplate.
	NotFoundHandler = http.HandlerFunc(NotFound)
)

// 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)
}