package main import ( "io/ioutil" "log" "net/http" ) func index(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write([]byte(`{"status": "error", "code": 20, "desc": "Database not ready"}`)) if r.Body != nil { req, e := ioutil.ReadAll(r.Body) if e != nil { panic(e) } log.Println("request body:", string(req)) } } func main() { http.HandleFunc("/", index) log.Println("listen 127.0.0.1:8080") http.ListenAndServe(":8080", nil) }