StatusApp/server/api.go

24 lines
523 B
Go

2020-04-23 07:42:16 +07:00
package server
import (
"encoding/json"
"net/http"
)
func writeJSON(w http.ResponseWriter, a interface{}) {
bytes, err := json.Marshal(a)
if err != nil {
http.Error(w, "500 Internal Server Error", http.StatusInternalServerError)
}
w.Header().Set("Content-Type", "application/json")
_, err = w.Write(bytes)
if err != nil {
http.Error(w, "500 Internal Server Error", http.StatusInternalServerError)
}
2020-04-23 07:42:16 +07:00
}
func allStatus(w http.ResponseWriter, req *http.Request) {
status := getStatus()
writeJSON(w, status)
}