INIT
This commit is contained in:
parent
d9a1837f3b
commit
ebd2f05ae2
69 changed files with 2335 additions and 451 deletions
65
backend.old/webapp.go
Normal file
65
backend.old/webapp.go
Normal file
|
@ -0,0 +1,65 @@
|
|||
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 *SseStream
|
||||
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()
|
||||
|
||||
displayH := router.Group("/displayh")
|
||||
displayH.Static("/", "./static/displayh")
|
||||
|
||||
displayV := router.Group("/displayv")
|
||||
displayV.Static("/", "./static/displayv")
|
||||
|
||||
priority := router.Group("/priority")
|
||||
priority.Static("/", "./static/priority")
|
||||
|
||||
mobile := router.Group("/mobile")
|
||||
mobile.Static("/", "./static/mobile")
|
||||
|
||||
setup := router.Group("/setup")
|
||||
setup.Static("/", "./static/setup")
|
||||
|
||||
draws := router.Group("/draws")
|
||||
draws.Static("/", "./static/draws")
|
||||
|
||||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue