mirror of
https://github.com/signaller-matrix/signaller.git
synced 2024-11-09 12:11:03 +00:00
20 lines
397 B
Go
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())
|
|
}
|
|
}
|