package main import ( "io" "net/http" "log" ) func main() { http.HandleFunc("/", func(resp http.ResponseWriter, req *http.Request) { switch req.Method { case http.MethodGet: _, _ = resp.Write([]byte("Try POSTing data to /")) case http.MethodPost: _, _ = io.Copy(resp, req.Body) default: http.Error(resp, "", http.StatusNotFound) } }) log.Println("Listening on http://127.0.0.1:3001") _ = http.ListenAndServe("127.0.0.1:3001", http.DefaultServeMux) }