2023-04-21 03:21:46 +01:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2023-04-24 15:36:21 +01:00
|
|
|
// RespondHttpStatus outputs the status code and text using http.Error()
|
2023-04-21 03:21:46 +01:00
|
|
|
func RespondHttpStatus(rw http.ResponseWriter, status int) {
|
2023-06-20 16:59:39 +01:00
|
|
|
http.Error(rw, fmt.Sprintf("%d %s", status, http.StatusText(status)), status)
|
2023-04-21 03:21:46 +01:00
|
|
|
}
|
2023-06-03 19:33:06 +01:00
|
|
|
|
|
|
|
func RespondVioletError(rw http.ResponseWriter, status int, msg string) {
|
|
|
|
rw.Header().Set("X-Violet-Error", msg)
|
|
|
|
RespondHttpStatus(rw, status)
|
|
|
|
}
|