重构状态处理

This commit is contained in:
xugo
2025-06-14 18:11:36 +08:00
parent 57a9a5b42e
commit 3fc455ecdd
16 changed files with 114 additions and 15 deletions
+22 -1
View File
@@ -14,6 +14,7 @@ import (
"strings"
"time"
"github.com/gin-contrib/cors"
"github.com/gin-contrib/gzip"
"github.com/gin-gonic/gin"
"github.com/gowvp/gb28181/plugin/stat"
@@ -48,6 +49,24 @@ func setupRouter(r *gin.Engine, uc *Usecase) {
)
go web.CountGoroutines(10*time.Minute, 20)
r.Use(cors.New(cors.Config{
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"},
AllowHeaders: []string{
"Accept", "Content-Length", "Content-Type", "Range", "Accept-Language",
"Origin", "Authorization",
"Accept-Encoding",
"Cache-Control", "Pragma", "X-Requested-With",
"Sec-Fetch-Mode", "Sec-Fetch-Site", "Sec-Fetch-Dest",
"Dnt", "X-Forwarded-For", "X-Forwarded-Proto", "X-Forwarded-Host",
"X-Real-IP", "X-Request-ID", "X-Request-Start", "X-Request-Time",
},
AllowCredentials: true,
MaxAge: 12 * time.Hour,
AllowOriginFunc: func(origin string) bool {
return true
},
}))
const staticPrefix = "/web"
const staticDir = "www"
admin := r.Group(staticPrefix, gzip.Gzip(gzip.DefaultCompression))
@@ -177,7 +196,9 @@ func sortExpvarMap(data *expvar.Map, top int) []KV {
}
func (uc *Usecase) proxySMS(c *gin.Context) {
defer recover()
defer func() {
_ = recover()
}()
rc := http.NewResponseController(c.Writer)
exp := time.Now().AddDate(99, 0, 0)