基本路由

gin 框架中采用的路由库是基于 httprouter 做的

地址为: https://github.com/julienschmidt/httprouter open in new window

package main

import (
    "net/http"

    "github.com/gin-gonic/gin"
)

func main() {
    r := gin.Default()
    r.GET("/", func(c *gin.Context) {
        c.String(http.StatusOK, "hello word")
    })
    r.POST("/xxxpost",getting)
    r.PUT("/xxxput")
    //监听端口默认为 8080
    r.Run(":8000")
}