mirror of
https://github.com/1f349/violet.git
synced 2024-11-09 14:12:58 +00:00
17 lines
409 B
Go
17 lines
409 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
// RespondHttpStatus outputs the status code and text using http.Error()
|
|
func RespondHttpStatus(rw http.ResponseWriter, status int) {
|
|
http.Error(rw, fmt.Sprintf("%d %s", status, http.StatusText(status)), status)
|
|
}
|
|
|
|
func RespondVioletError(rw http.ResponseWriter, status int, msg string) {
|
|
rw.Header().Set("X-Violet-Error", msg)
|
|
RespondHttpStatus(rw, status)
|
|
}
|