开启http服务
func HttpService() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// r.FormValue() 获取参数
name := r.FormValue("name")
id := r.FormValue("id")
status := r.FormValue("status")
w.Write([]byte(name + id + status + "\n"))
w.Write([]byte(r.Host + "\n"))
w.Write([]byte(r.RemoteAddr + "\n"))
w.Write([]byte(r.RequestURI + "\n"))
w.Write([]byte(r.UserAgent() + "\n"))
})
http.ListenAndServe("127.0.0.1:8080", nil)
}
有疑问加站长微信联系(非本文作者)