x/net/http/status_handler.go

22 lines
390 B
Go
Raw Normal View History

2020-06-14 23:12:32 -04:00
package http
import (
"io"
"net/http"
)
// boosted from @matryer
type StatusHandler int
func (s StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
code := int(s)
w.WriteHeader(code)
io.WriteString(w, http.StatusText(code))
}
var (
NotFoundHandler = StatusHandler(404)
NotImplementedHandler = StatusHandler(501)
NotLegalHandler = StatusHandler(451)
)