Gin安裝

Gin安裝
Download and install it:
$ go get gopkg.in/gin-gonic/gin.v1
Import it in your code:
import “gopkg.in/gin-gonic/gin.v1”
(Optional) Import net/http. This is required for example if using constants such as http.StatusOK.
import “net/http”

API Examples
Using GET, POST, PUT, PATCH, DELETE and OPTIONS
func main() {
// Creates a gin router with default middleware:
// logger and recovery (crash-free) middleware
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)

// By default it serves on :8080 unless a
// PORT environment variable was defined.
router.Run()
// router.Run(":3000") for a hard coded port

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章