mirror of
https://github.com/documize/community.git
synced 2025-07-24 23:59:47 +02:00
keycloak aiurth service JS code refactoring
This commit is contained in:
parent
0f9d673eb5
commit
0fedfb199b
7 changed files with 88 additions and 79 deletions
|
@ -146,7 +146,6 @@ func WriteMarshalError(w http.ResponseWriter, err error) {
|
|||
w.WriteHeader(http.StatusBadRequest)
|
||||
_, err2 := w.Write([]byte("{Error: 'JSON marshal failed'}"))
|
||||
log.IfErr(err2)
|
||||
log.Error("Failed to JSON marshal", err)
|
||||
}
|
||||
|
||||
// WriteJSON serializes data as JSON to HTTP response.
|
||||
|
@ -165,6 +164,15 @@ func WriteJSON(w http.ResponseWriter, v interface{}) {
|
|||
log.IfErr(err)
|
||||
}
|
||||
|
||||
// WriteRequestError sends custom error message.
|
||||
func WriteRequestError(w http.ResponseWriter, msg string) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
|
||||
_, err := w.Write([]byte(fmt.Sprintf("{Error: '%s'}", msg)))
|
||||
log.IfErr(err)
|
||||
}
|
||||
|
||||
// WriteBadLicense writes 402 when license is invalid
|
||||
func WriteBadLicense(w http.ResponseWriter) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue