-
Notifications
You must be signed in to change notification settings - Fork 23
/
main.go
35 lines (26 loc) · 772 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
package main
import (
"flag"
"log"
"path/filepath"
"github.com/gin-gonic/gin"
"github.com/hyperjiang/gin-skeleton/config"
"github.com/hyperjiang/gin-skeleton/router"
)
func main() {
addr := flag.String("addr", config.Server.Addr, "Address to listen and serve")
flag.Parse()
if config.Server.Mode == gin.ReleaseMode {
gin.DisableConsoleColor()
}
app := gin.Default()
app.Static("/images", filepath.Join(config.Server.StaticDir, "img"))
app.StaticFile("/favicon.ico", filepath.Join(config.Server.StaticDir, "img/favicon.ico"))
app.LoadHTMLGlob(config.Server.ViewDir + "/*")
app.MaxMultipartMemory = config.Server.MaxMultipartMemory << 20
router.Route(app)
// Listen and Serve
if err := app.Run(*addr); err != nil {
log.Fatal(err.Error())
}
}