-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (31 loc) · 925 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"github.com/gin-contrib/gzip"
"github.com/gin-contrib/static"
"github.com/gin-gonic/gin"
"github.com/thinkerou/favicon"
"go-vue-start-kit/routes"
)
func main() {
// Default With the Logger and Recovery middleware already attached
router := gin.Default()
router.Use(gzip.Gzip(gzip.DefaultCompression))
api := router.Group("/api")
//api.Use(AuthRequired())
{
api.GET("/get/:user", routes.GetTest)
api.POST("/post/:user", routes.PostTest)
api.POST("/login", routes.Login)
}
//router.LoadHTMLGlob("views/**/*")
//router.GET("/", func(c *gin.Context) {
// c.HTML(http.StatusOK, "index.html", nil)
//})
//router.StaticFile("/favicon.ico", "./public/favicon.ico")
router.Use(favicon.New("./public/favicon.ico"))
router.Use(static.Serve("/", static.LocalFile("./public", true)))
router.NoRoute(func(c *gin.Context) {
c.File("./public/index.html")
})
router.Run(":8080")
}