gin获取post中json

  开发

func PostJson(c *gin.Context) {
    data, err := ioutil.ReadAll(c.Request.Body)
    if err != nil {
        c.JSON(http.StatusOK, gin.H{
            "error": err,
        })
    } else {
        c.JSON(http.StatusOK, gin.H{
            "json": string(data),
        })
    }
}

LEAVE A COMMENT

Captcha Code