1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
func main() {
// 使用默认中间件创建一个gin路由器:
router := gin.Default()
// 路由映射
router.GET("/someGet", getting)
router.POST("/somePost", posting)
router.PUT("/somePut", putting)
router.DELETE("/someDelete", deleting)
router.PATCH("/somePatch", patching)
router.HEAD("/someHead", head)
router.OPTIONS("/someOptions", options)
// 启动,可设置端口
router.Run()
// router.Run(":3000") for a hard coded port
}
|