golang接收post接收xml或者json数据

import (
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    http.HandleFunc("/", myHandle)
    http.ListenAndServe(":8888", nil)
}

func myHandle(w http.ResponseWriter, r *http.Request) {
    defer r.Body.Close()
    con, _ := ioutil.ReadAll(r.Body) //获取post的数据
    fmt.Println(string(con))

}

猜你喜欢

转载自www.cnblogs.com/enumx/p/12315600.html
今日推荐