alai-server/backend/utils/json.go
2022-06-29 21:26:05 -04:00

17 lines
357 B
Go

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})
}