上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 50 下一页
摘要: ★全局中间件 所有请求都经过此中间件 package main import ( "fmt" "time" "github.com/gin-gonic/gin" ) // 定义中间 func MiddleWare() gin.HandlerFunc { return func(c *gin.Cont 阅读全文
posted @ 2021-06-28 22:51 创客未来 阅读(79) 评论(0) 推荐(0) 编辑
摘要: ★json、结构体、XML、YAML类似于java的properties、ProtoBuf package main import ( "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/testdata/protoexample" ) // 多 阅读全文
posted @ 2021-06-28 21:56 创客未来 阅读(520) 评论(0) 推荐(0) 编辑
摘要: ★Json数据解析和绑定 客户端传参,后端接收并解析到结构体 package main import ( "net/http" "github.com/gin-gonic/gin" ) // 定义接收数据的结构体 type Login struct { // binding:"required"修饰 阅读全文
posted @ 2021-06-28 21:47 创客未来 阅读(285) 评论(0) 推荐(0) 编辑
摘要: ★Json数据解析和绑定 客户端传参,后端接收并解析到结构体 package main import ( "net/http" "github.com/gin-gonic/gin" ) // 定义接收数据的结构体 type Login struct { // binding:"required"修饰 阅读全文
posted @ 2021-06-28 21:42 创客未来 阅读(89) 评论(0) 推荐(0) 编辑
摘要: ★基本的路由注册 最基础的gin路由注册方式,适用于路由条目比较少的简单项目或者项目demo package main import ( "fmt" "net/http" "github.com/gin-gonic/gin" ) func helloHander(c *gin.Context) { 阅读全文
posted @ 2021-06-28 21:30 创客未来 阅读(114) 评论(0) 推荐(0) 编辑
摘要: routes group是为了管理一些相同的URL package main import ( "fmt" "github.com/gin-gonic/gin" ) //gin的helloWorld func main() { //1.创建路由 // 默认使用了2个中间件件Logger(),Reco 阅读全文
posted @ 2021-06-28 20:47 创客未来 阅读(218) 评论(0) 推荐(0) 编辑
摘要: ★单个文件上传 multipart/form-data格式用于文件上传 gin文件上传与原生的net/http方法类似,不同在于gin把原生的request封装到c.Request中 html前端代码: <!DOCTYPE html> <html lang="en"> <head> <meta ch 阅读全文
posted @ 2021-06-28 17:39 创客未来 阅读(545) 评论(0) 推荐(0) 编辑
摘要: 表单传输为post请求,http常见的传输格式为四种: application/json application/x-www-form-urlencoded application/xml multipart/form-data 表单参数可以通过PostForm()方法获取,该方法默认解析的是x-w 阅读全文
posted @ 2021-06-28 17:31 创客未来 阅读(147) 评论(0) 推荐(0) 编辑
摘要: URL参数可以通过DefaultQuery()或Query()方法获取 DefaultQuery()若参数不存在,返回默认值,Query()若不存在,返回空串 API ? name=zs package main import ( "fmt" "net/http" "github.com/gin-g 阅读全文
posted @ 2021-06-28 17:17 创客未来 阅读(642) 评论(0) 推荐(0) 编辑
摘要: ★《奥利佛·推斯特》 作者:狄更斯(英国) 英国批判现实主义文学的杰出代表。揭示了劳资对立,具有啊强烈的批精神和浓厚的资产阶级人道主义色彩。 作品: ①早期:《皮克威克外传》《奥利佛·推斯特》《老古玩店》。作品基调较为乐观,以下层小人物收到人次的资产者保护为结局。 ②40年代后:《马丁·朱述尔维特》 阅读全文
posted @ 2021-06-28 17:06 创客未来 阅读(328) 评论(0) 推荐(0) 编辑
上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 50 下一页