You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
932 B
51 lines
932 B
package main
|
|
|
|
import (
|
|
"cmsDemo/models"
|
|
"cmsDemo/utils"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/spf13/viper"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
// 解析配置
|
|
utils.ParseConfig()
|
|
utils.InitDB()
|
|
models.Migrate()
|
|
|
|
// 初始化默认路由
|
|
router := gin.Default()
|
|
// 定义路径和处理函数的匹配关系
|
|
// 添加tag
|
|
router.POST("tag", func(ctx *gin.Context) {
|
|
ctx.JSON(http.StatusOK, gin.H{
|
|
"message": "tag post",
|
|
})
|
|
})
|
|
// 删除tag
|
|
router.DELETE("tag", func(ctx *gin.Context) {
|
|
ctx.JSON(http.StatusOK, gin.H{
|
|
"message": "tag delete",
|
|
})
|
|
})
|
|
// 更新tag
|
|
router.PUT("tag", func(ctx *gin.Context) {
|
|
ctx.JSON(http.StatusOK, gin.H{
|
|
"message": "tag put",
|
|
})
|
|
})
|
|
// 查询tag
|
|
router.GET("tag", func(ctx *gin.Context) {
|
|
ctx.JSON(http.StatusOK, gin.H{
|
|
"message": "tag get",
|
|
})
|
|
})
|
|
|
|
// 启动监听
|
|
if err := router.Run(viper.GetString("app.addr")); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|