ルーティンググループ

package main

import (
    "github.com/gin-gonic/gin"
    "net/http"
)


func main() { //代码块

    router := gin.Default()
    v1:=router.Group("/v1/topics")

    {
        v1.GET("", func(context *gin.Context) {
            context.String(http.StatusOK,"获取帖子列表")
        })
        v1.GET("/:topic_id", func(c *gin.Context) {
            c.String(http.StatusOK,"获取用户名=%s的帖子列表",c.Query("username"))
        })
        router.Run()
    }

}




おすすめ

転載: www.cnblogs.com/hualou/p/12071045.html