Files
x/net/http/status_handler.go
T

23 lines
537 B
Go
Raw Normal View History

2020-06-14 20:12:32 -07: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)
2020-10-23 21:55:48 -07:00
_, _ = io.WriteString(w, http.StatusText(code))
2020-06-14 20:12:32 -07:00
}
var (
NotFoundHandler = StatusHandler(http.StatusNotFound)
NotImplementedHandler = StatusHandler(http.StatusNotImplemented)
NotLegalHandler = StatusHandler(http.StatusUnavailableForLegalReasons)
NotAllowedHandler = StatusHandler(http.StatusMethodNotAllowed)
2020-06-14 20:12:32 -07:00
)