mirror of
https://github.com/signaller-matrix/signaller.git
synced 2024-11-13 22:21:02 +00:00
20 lines
406 B
Go
20 lines
406 B
Go
package internal
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/signaller-matrix/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())
|
|
}
|
|
}
|