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))

}

你可能感兴趣的:(golang接收post接收xml或者json数据)