-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
60 lines (48 loc) · 1.18 KB
/
main.go
File metadata and controls
60 lines (48 loc) · 1.18 KB
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
package main
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
)
func main() {
const viewPath string = "view/"
router := gin.Default()
router.Static("/static", viewPath+"static")
router.LoadHTMLGlob(viewPath + "templates/**/*.html")
upgrader := websocket.Upgrader{}
router.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "about-me.html", gin.H{
"title": "Carl Eric Doromal - About Me",
})
})
router.GET("/projects", func(c *gin.Context) {
c.HTML(http.StatusOK, "projects.html", gin.H{
"title": "Carl Eric Doromal - Projects",
})
})
router.GET("/international", func(c *gin.Context) {
c.HTML(http.StatusOK, "international.html", gin.H{
"title": "Carl Eric Doromal - International",
})
})
router.GET("/health", func(c *gin.Context) {
c.String(http.StatusOK, "OK")
})
router.GET("/live-reload", func(c *gin.Context) {
conn, err := upgrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
log.Println("Websocket Upgrade Error:", err)
return
}
defer conn.Close()
for {
_, _, err := conn.ReadMessage()
if err != nil {
log.Println("Read Error:", err)
break
}
}
})
router.Run(":8080")
}