摘要:
先上代码 func In(haystack []interface{}, needle interface{}) (bool, error) { sVal := reflect.ValueOf(haystack) kind := sVal.Kind() if kind == reflect.Slic 阅读全文
摘要:
在 gin中,通过默认的函数,构建一个实现了带默认中间件的 *Engine。 r := gin.Default() 默认绑定了Logger和Recovery中间件,帮助我们进行日志输出和错误处理。 func Default() *Engine { debugPrintWARNINGDefault() 阅读全文
摘要:
https://draveness.me/golang-101/ 阅读全文
摘要:
package main import ( "github.com/gin-gonic/gin" ) type User struct { Id int `json:"id"` Name string `json:"name"` Age int `json:"age"` } func main() 阅读全文
摘要:
package mainimport ( "github.com/gin-gonic/gin")func main() { router := gin.Default() v1RouterGroup := router.Group("/v1") { v1RouterGroup.GET("/users 阅读全文
摘要:
curl http://127.0.0.1:8080/users -X POST -d 'name=juanmaofeifei&age=10' package main import ( "github.com/gin-gonic/gin" "strconv" ) func main() { rou 阅读全文
摘要:
GET url: http://127.0.0.1:8080/users?id=1&name=卷毛狒狒 package mainimport ( "github.com/gin-gonic/gin" "strconv")func main() { router := gin.Default() ro 阅读全文
摘要:
GET url: http://127.0.0.1:8080/users/{id} http://127.0.0.1:8080/users/1 对于id值的获取 package main import ( "github.com/gin-gonic/gin" ) func main() { rout 阅读全文
摘要:
package mainimport ( "github.com/gin-gonic/gin")func main() { router := gin.Default() router.GET("/user", func(c *gin.Context) { c.JSON(200 , gin.H{ " 阅读全文
摘要:
package mainimport ( "github.com/gin-gonic/gin")func main() { router := gin.Default() router.GET("/user", func(c *gin.Context) { c.JSON(200 , gin.H{ " 阅读全文