baisc structure and server begin server impl

This commit is contained in:
Livio Amstutz 2019-11-18 15:37:48 +01:00
parent 26bd873f4e
commit f6ba7ab75e
17 changed files with 575 additions and 0 deletions

18
pkg/utils/marshal.go Normal file
View file

@ -0,0 +1,18 @@
package utils
import (
"encoding/json"
"net/http"
"github.com/caos/utils/logging"
)
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)
logging.Log("UTILS-zVu9OW").OnError(err).Error("error writing response")
}