美文网首页
Golang http服务

Golang http服务

作者: 懒人程序猿 | 来源:发表于2020-03-25 14:25 被阅读0次

    开启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)
    }
    

    相关文章

      网友评论

          本文标题:Golang http服务

          本文链接:https://www.haomeiwen.com/subject/ehotuhtx.html