Created
March 10, 2022 08:39
-
-
Save weaming/c8ada49de7c92b9e26f65acd096f7cc2 to your computer and use it in GitHub Desktop.
Revisions
-
weaming created this gist
Mar 10, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ 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) }