alai-server/backend/utils/json.go

17 lines
357 B
Go
Raw Permalink Normal View History

2022-06-29 21:26:05 -04:00
package utils
import (
"encoding/json"
"net/http"
)
type ErrorMessage struct {
ErrorMessage string `json:"error_message"`
}
func JSONErrorOutput(writer http.ResponseWriter, status int, msg string) {
writer.Header().Set("Content-Type", "application/json")
writer.WriteHeader(status)
json.NewEncoder(writer).Encode(ErrorMessage{ErrorMessage: msg})
}