StatusApp/server/api.go

21 lines
417 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")
w.Write(bytes)
}
func allStatus(w http.ResponseWriter, req *http.Request) {
status := getStatus()
writeJSON(w, status)
}