mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
24 lines
504 B
Go
24 lines
504 B
Go
package http
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/zitadel/logging"
|
|
)
|
|
|
|
func MarshalJSON(w http.ResponseWriter, i interface{}, err error, statusCode int) {
|
|
if err != nil {
|
|
http.Error(w, err.Error(), statusCode)
|
|
return
|
|
}
|
|
b, err := json.Marshal(i)
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
w.Header().Set("content-type", "application/json")
|
|
_, err = w.Write(b)
|
|
logging.Log("HTTP-sdgT2").OnError(err).Error("error writing response")
|
|
}
|