plapkit/responses.go
2024-06-26 21:18:24 -04:00

39 lines
1.1 KiB
Go

package main
import "net/http"
func errMethodNotAllowed(rw http.ResponseWriter) {
rw.Header().Add("content-type", "text/plain")
rw.WriteHeader(http.StatusMethodNotAllowed)
rw.Write([]byte("405 Method Not Allowed"))
}
func errStatusInternalServerError(rw http.ResponseWriter) {
rw.Header().Add("content-type", "text/plain")
rw.WriteHeader(http.StatusInternalServerError)
rw.Write([]byte("500 Internal Server Error"))
}
func errUnauthorized(rw http.ResponseWriter) {
rw.Header().Add("content-type", "text/plain")
rw.WriteHeader(http.StatusUnauthorized)
rw.Write([]byte("401 Unauthorized"))
}
func errBadRequest(rw http.ResponseWriter) {
rw.Header().Add("content-type", "text/plain")
rw.WriteHeader(http.StatusBadRequest)
rw.Write([]byte("401 Bad Request"))
}
func basicOk(rw http.ResponseWriter) {
rw.Header().Add("content-type", "text/plain")
rw.WriteHeader(http.StatusOK)
rw.Write([]byte("200 Aight Request"))
}
func basicNoContent(rw http.ResponseWriter) {
rw.Header().Add("content-type", "text/plain")
rw.WriteHeader(http.StatusNoContent)
rw.Write([]byte("204 No Content (debug: likely not handled)"))
}