1.基本代码
package main
import (
"github.com/gin-gonic/gin"
)
func testget(c *gin.Context) {
c.JSON(200, gin.H{
"data": "get",
})
}
func main() {
router := gin.Default()
router.GET("/login", testget)
router.Run()
2.支持get、post、put、delete、patch、head、option等方法
func main() {
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()
}