replace zxq.co/ripple/hanayo
This commit is contained in:
39
vendor/github.com/gin-gonic/gin/examples/realtime-advanced/main.go
generated
vendored
Normal file
39
vendor/github.com/gin-gonic/gin/examples/realtime-advanced/main.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ConfigRuntime()
|
||||
StartWorkers()
|
||||
StartGin()
|
||||
}
|
||||
|
||||
func ConfigRuntime() {
|
||||
nuCPU := runtime.NumCPU()
|
||||
runtime.GOMAXPROCS(nuCPU)
|
||||
fmt.Printf("Running with %d CPUs\n", nuCPU)
|
||||
}
|
||||
|
||||
func StartWorkers() {
|
||||
go statsWorker()
|
||||
}
|
||||
|
||||
func StartGin() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
router := gin.New()
|
||||
router.Use(rateLimit, gin.Recovery())
|
||||
router.LoadHTMLGlob("resources/*.templ.html")
|
||||
router.Static("/static", "resources/static")
|
||||
router.GET("/", index)
|
||||
router.GET("/room/:roomid", roomGET)
|
||||
router.POST("/room-post/:roomid", roomPOST)
|
||||
router.GET("/stream/:roomid", streamRoom)
|
||||
|
||||
router.Run(":80")
|
||||
}
|
Reference in New Issue
Block a user