***********************************************************中间件*****************
跨中间件存取值的方法,如在中间件A中存入某值,执行到B中间件时 取出A中存的值方法如下
*******************************************************************路由组********************************************
创建/route 并在其下创建 route.go
package route import ( "GinMysql/contraller" "github.com/gin-gonic/gin" "net/http" ) func SetUpRoute() *gin.Engine{ engin:=gin.Default() engin.LoadHTMLFiles("./view/user/Users") //engin.LoadHTMLFiles("./view/user/AddUser") group:= engin.Group("/user") { group.GET("/Users", contraller.GetAllUser) group.POST("/modify/:id", contraller.AddUser) group.POST("/AddUser",contraller.AddUser) group.GET("/delete/:id",contraller.DeleteUser) } engin.GET("/AddUser",contraller.AddUser) engin.GET("/MyHtml", func(c *gin.Context) { engin.LoadHTMLFiles("./view/MyHtml") c.HTML(http.StatusOK,"MyHtml",true) }) return engin }
main 里面的代码
func main(){ engin:= route.SetUpRoute() engin.Run(":8090") }
************************************* /xxx/xxx参数*******************************************************************
********************************************** shouldbind将参数绑定到对像**************************************************************