-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (32 loc) · 853 Bytes
/
main.go
File metadata and controls
37 lines (32 loc) · 853 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
package main
import (
"elderflower/config"
"elderflower/controllers"
"elderflower/middleware"
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
r := gin.Default()
//Initialize middlewares
r.Use(middleware.Middlewares()...)
//Statics, Javascripts and templates
r.Static("/public", "./compiled/public")
r.Static("/jsx", "./compiled/jsx")
r.Static("/css", "./compiled/css")
r.LoadHTMLGlob("compiled/html/*")
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", nil)
})
//Application routes
r.POST("/users", controllers.User_Create)
r.GET("/QR", controllers.QR)
r.GET("/ping", func(c *gin.Context) {
c.String(http.StatusOK, "pong")
})
r.GET("/websocket", func(c *gin.Context) {
controllers.HandleSocket(c)
})
r.POST("/messages/receive", controllers.Messages_Receive)
r.Run(":" + config.Get("PORT"))
}