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