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 (
|
2022-07-08 12:48:05 -07:00
|
|
|
NotFoundHandler = StatusHandler(http.StatusNotFound)
|
|
|
|
|
NotImplementedHandler = StatusHandler(http.StatusNotImplemented)
|
|
|
|
|
NotLegalHandler = StatusHandler(http.StatusUnavailableForLegalReasons)
|
|
|
|
|
NotAllowedHandler = StatusHandler(http.StatusMethodNotAllowed)
|
2020-06-14 20:12:32 -07:00
|
|
|
)
|