Priority/backend/webapp.go

57 lines
1 KiB
Go
Raw Normal View History

2023-12-05 13:48:13 +01:00
package main
import (
"log"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
scribble "github.com/nanobox-io/golang-scribble"
)
type Webapp struct {
Engine *gin.Engine
Stream *PriorityStream
DB *scribble.Driver
}
const _MaxLen = 8
func InitHttp(d *scribble.Driver) *Webapp {
router := gin.Default()
router.Use(cors.Default())
wapp := &Webapp{
Engine: router,
DB: d,
}
wapp.initApi()
// wapp.initAuth()
display := router.Group("/display")
display.Static("/", "./static/display")
video := router.Group("/videowall")
video.Static("/", "./static/videowall")
priority := router.Group("/priority")
priority.Static("/", "./static/priority")
sapp := router.Group("/_app")
sapp.Static("/", "./static/_app")
static := router.Group("/static")
static.Static("/", "./static/static")
router.StaticFile("/", "./static/index.html")
router.StaticFile("/favicon.png", "./static/favicon.png")
router.ForwardedByClientIP = true
router.SetTrustedProxies([]string{"127.0.0.1"})
log.Printf("WebApp: %+v", wapp)
return wapp
}