摘要: 1. 单文件上传 package main import ( "fmt" "github.com/gin-gonic/gin" "log" ) func main() { router := gin.Default() //为 multipart forms 设置较低的内存限制 (默认是 32 Mi 阅读全文
posted @ 2021-10-20 16:30 专职 阅读(190) 评论(0) 推荐(0) 编辑
摘要: package main import ( "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/testdata/protoexample" ) func main() { router := gin.Default() router.GET(" 阅读全文
posted @ 2021-10-20 15:39 专职 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 使用 SecureJSON 防止 json 劫持。如果给定的结构是数组值或map,则默认预置 "while(1)," 到响应体。 package main import ( "github.com/gin-gonic/gin" ) func main() { router := gin.Defaul 阅读全文
posted @ 2021-10-20 14:49 专职 阅读(470) 评论(0) 推荐(0) 编辑
摘要: package main import ( "github.com/gin-gonic/gin" ) func main() { r := gin.Default() // Query和PostForm r.GET("/post", func(c *gin.Context) { id := c.Qu 阅读全文
posted @ 2021-10-20 14:22 专职 阅读(350) 评论(0) 推荐(0) 编辑
摘要: package main import ( "github.com/gin-gonic/gin" ) func main() { router := gin.Default() router.POST("/form_post", func(c *gin.Context) { // 接收post表单提 阅读全文
posted @ 2021-10-20 13:59 专职 阅读(125) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "github.com/gin-gonic/gin" "net/http" ) type LoginForm struct { // form:"user" 表示前端提交form表单时User对应的key的名称为:user // binding 阅读全文
posted @ 2021-10-20 13:46 专职 阅读(140) 评论(0) 推荐(0) 编辑
摘要: package main import ( "github.com/gin-gonic/gin" "net/http" ) func main() { r := gin.Default() r.GET("/jsonp", func(context *gin.Context) { data := ma 阅读全文
posted @ 2021-10-20 11:12 专职 阅读(112) 评论(0) 推荐(0) 编辑