x/net/http/status_handler.go
2020-10-23 21:55:48 -07:00

22 lines
397 B
Go

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