GET请求
两种常见情况
og.GET("/file/:name", Controller.UploadControl.DownloadFile)
http://localhost:8082/og/file/test.jpg
func (* UploadController)DownloadFile(c *gin.Context) {
name := c.Param("name")
}
og.GET("/file", Controller.UploadControl.DownloadFile)
http://localhost:8082/og/file?f=test.jpg
func (* UploadController)DownloadFile(c *gin.Context) {
name := c.Query("f")
}
POST请求
data, err := ioutil.ReadAll(c.Request.Body)
CheckError(err)
var msg struct {
Ids []int
}
json.Unmarshal(data, &msg)
FORM请求
用来文件上传
file, _ := c.FormFile("file")