signaller/internal/errors.go
2019-08-03 11:46:57 +05:00

20 lines
397 B
Go

package internal
import (
"net/http"
"github.com/nxshock/signaller/internal/models"
)
func errorResponse(w http.ResponseWriter, code models.ApiError, httpCode int, messageOverride string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(httpCode)
if messageOverride != "" {
w.Write(models.NewError(code, messageOverride).JSON())
} else {
w.Write(code.JSON())
}
}