基本路由
发布者:admin 发表于:439天前 阅读数:2348 评论:0

基本路由

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

地址为:https://github.com/julienschmidt/httprouter

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")
}