-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwapiti.go
93 lines (76 loc) · 2.16 KB
/
wapiti.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"net/http"
"github.com/gin-gonic/contrib/renders/multitemplate"
"github.com/gin-gonic/gin"
)
func main() {
//define main router
router := gin.Default()
//define templates
templates := multitemplate.New()
templates.AddFromFiles("index", "pages/layout.html", "pages/index.html")
templates.AddFromFiles("logs", "pages/layout.html", "pages/logs.html")
templates.AddFromFiles("packages", "pages/layout.html", "pages/packages.html")
templates.AddFromFiles("parameters", "pages/layout.html", "pages/parameters.html")
templates.AddFromFiles("rule", "pages/layout.html", "pages/rule.html")
templates.AddFromFiles("rules", "pages/layout.html", "pages/rules.html")
templates.AddFromFiles("script", "pages/layout.html", "pages/script.html")
templates.AddFromFiles("scripts", "pages/layout.html", "pages/scripts.html")
router.HTMLRender = templates
//set static
router.Static("/assets", "./assets")
//router.StaticFS("/more_static", http.Dir("my_file_system"))
//Routes
router.GET("/index", renderIndex)
router.GET("/logs", renderLogs)
router.GET("/packages", renderPackages)
router.GET("/parameters", renderParameters)
router.GET("/rule/:id", renderRule)
router.GET("/rules", renderRules)
router.GET("/script/:id", renderScript)
router.GET("/scripts", renderScripts)
//Default route
router.NoRoute(func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/index") })
router.Run(":3000")
}
func renderIndex(c *gin.Context) {
c.HTML(200, "index", gin.H{
"title": "Accueil",
})
}
func renderLogs(c *gin.Context) {
c.HTML(200, "logs", gin.H{
"title": "Journaux",
})
}
func renderPackages(c *gin.Context) {
c.HTML(200, "packages", gin.H{
"title": "Packages",
})
}
func renderParameters(c *gin.Context) {
c.HTML(200, "parameters", gin.H{
"title": "Paramètres",
})
}
func renderRule(c *gin.Context) {
c.HTML(200, "rule", gin.H{
"title": "Règle",
})
}
func renderRules(c *gin.Context) {
c.HTML(200, "rules", gin.H{
"title": "Règles",
})
}
func renderScript(c *gin.Context) {
c.HTML(200, "script", gin.H{
"title": "Script",
})
}
func renderScripts(c *gin.Context) {
c.HTML(200, "scripts", gin.H{
"title": "Scripts",
})
}