1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

Major refactorings.

Introduce summaries.
This commit is contained in:
Ferdinand Mütsch
2019-05-19 19:49:27 +02:00
parent 62e94f6635
commit be906805e7
14 changed files with 194 additions and 282 deletions

14
utils/http.go Normal file
View File

@ -0,0 +1,14 @@
package utils
import (
"encoding/json"
"net/http"
)
func RespondJSON(w http.ResponseWriter, status int, object interface{}) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
if err := json.NewEncoder(w).Encode(object); err != nil {
w.WriteHeader(http.StatusInternalServerError)
}
}