This commit is contained in:
CareyWong 2020-03-30 00:38:45 +08:00
parent b2324e60a8
commit 217e9274c6

View File

@ -42,6 +42,7 @@ var redisClient redis.Conn
func main() { func main() {
gin.SetMode(gin.ReleaseMode) gin.SetMode(gin.ReleaseMode)
router := gin.Default() router := gin.Default()
router.LoadHTMLGlob("public/*.html")
port := flag.Int("port", defaultPort, "服务端口") port := flag.Int("port", defaultPort, "服务端口")
domain := flag.String("domain", "", "短链接域名,必填项") domain := flag.String("domain", "", "短链接域名,必填项")
@ -67,6 +68,12 @@ func main() {
} }
initRedisPool() initRedisPool()
router.GET("/", func(context *gin.Context) {
context.HTML(http.StatusOK, "index.html", gin.H{
"title": "MyUrls",
})
})
router.POST("/short", func(context *gin.Context) { router.POST("/short", func(context *gin.Context) {
res := &Response{ res := &Response{
Code: 1, Code: 1,