zitadel-oidc/pkg/utils/marshal.go
2019-11-29 15:35:37 +01:00

20 lines
345 B
Go

package utils
import (
"encoding/json"
"net/http"
"github.com/sirupsen/logrus"
)
func MarshalJSON(w http.ResponseWriter, i interface{}) {
b, err := json.Marshal(i)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
_, err = w.Write(b)
if err != nil {
logrus.Error("error writing response")
}
}