24 lines
523 B
Go
24 lines
523 B
Go
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)
|
|
}
|
|
}
|
|
|
|
func allStatus(w http.ResponseWriter, req *http.Request) {
|
|
status := getStatus()
|
|
writeJSON(w, status)
|
|
}
|