代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/Monibuca 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"context"
"embed"
"flag"
"mime"
"net/http"
_ "net/http/pprof"
"os"
"os/signal"
"path"
"path/filepath"
"syscall"
. "github.com/Monibuca/engine/v3"
// _ "github.com/Monibuca/plugin-ffmpeg"
// _ "github.com/Monibuca/plugin-cluster"
_ "github.com/Monibuca/plugin-gateway/v3"
_ "github.com/Monibuca/plugin-gb28181/v3"
_ "github.com/Monibuca/plugin-hdl/v3"
_ "github.com/Monibuca/plugin-hls/v3"
_ "github.com/Monibuca/plugin-jessica/v3"
_ "github.com/Monibuca/plugin-logrotate/v3"
_ "github.com/Monibuca/plugin-record/v3"
_ "github.com/Monibuca/plugin-rtmp/v3"
_ "github.com/Monibuca/plugin-rtsp/v3"
_ "github.com/Monibuca/plugin-summary"
_ "github.com/Monibuca/plugin-ts/v3"
_ "github.com/Monibuca/plugin-webrtc/v3"
)
//go:embed ui/*
var ui embed.FS
func main() {
addr := flag.String("c", "config.toml", "config file")
flag.Parse()
if _, err := os.Stat(*addr); err == nil {
Run(*addr)
} else {
Run(filepath.Join(filepath.Dir(os.Args[0]), *addr))
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
filePath := r.URL.Path
if filePath == "/" {
filePath = "/index.html"
}
if mime := mime.TypeByExtension(path.Ext(filePath)); mime != "" {
w.Header().Set("Content-Type", mime)
}
if f, err := ui.ReadFile("ui" + filePath); err == nil {
w.Header().Set("Cache-Control","max-age=3600")
if _, err = w.Write(f); err != nil {
w.WriteHeader(505)
}
} else {
w.Header().Set("Location", "/")
w.WriteHeader(302)
}
})
waiter(context.Background())
}
func waiter(ctx context.Context) {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
defer signal.Stop(sigc)
<-sigc
ctx.Done()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。