标签:lin otto string img 设计 als fun topic yun
router := gin.Default()
router.GET("/topic/:topic_id", func(context *gin.Context) {
context.String(http.StatusOK,"获取帖子Id为%s",context.Param("topic_id"))
})
router.Run()
package main
import (
"github.com/gin-gonic/gin"
)
type Topic struct {
TopicID int
}
func main() {
router := gin.Default()
router.GET("/topic/:topic_id", func(c *gin.Context) {
if c.Query("username") == "" {
c.String(200,"获取帖子列表")
}else{
c.String(200,"获取用户名=%s的帖子列表",c.Query("username"))
}
})
router.GET("/v1/topics/:topic_id", func(c *gin.Context) {
c.String(200,"获取topic=%s的帖子列表",c.Param("topic_id"))
})
router.Run()
}
标签:lin otto string img 设计 als fun topic yun
原文地址:https://www.cnblogs.com/hualou/p/12071037.html