-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (31 loc) · 708 Bytes
/
main.go
File metadata and controls
40 lines (31 loc) · 708 Bytes
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-gonic/gin"
"github.com/grt1st/shortcut/core"
"github.com/grt1st/shortcut/handles"
"github.com/grt1st/shortcut/models"
)
func main() {
// init
core.Init()
models.InitSql()
server()
}
func server() {
router := gin.Default()
router.LoadHTMLGlob("templates/*")
//router.HTMLRender = handles.CreateRender()
// static can be handle by nginx
router.Static("/static", "./static")
// ping
router.GET("/ping", handles.Ping)
// homepage
router.GET("/", handles.Index)
// 404
router.GET("/404", handles.E404)
// save
router.POST("/new", handles.NewShortcut)
// shortcut
router.GET("/s/:shortcut", handles.GetShortcut)
router.Run(core.Config.Host)
}