增加罗列按需拉流的列表

This commit is contained in:
dexter
2023-03-09 19:45:56 +08:00
parent 6e88462228
commit 178789161d

22
main.go
View File

@@ -9,6 +9,7 @@ import (
"strings"
. "m7s.live/engine/v4"
"m7s.live/engine/v4/config"
)
//go:embed ui
@@ -21,13 +22,28 @@ func (p *PreviewConfig) OnEvent(event any) {
}
var plugin = InstallPlugin(&PreviewConfig{})
var _ = InstallPlugin(&PreviewConfig{})
func (p *PreviewConfig) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/preview/" {
Streams.Range(func(streamPath string, s *Stream) {
w.Write([]byte(fmt.Sprintf("<a href='%s'>%s</a><br>", streamPath, streamPath)))
var s string
Streams.Range(func(streamPath string, _ *Stream) {
s += fmt.Sprintf("<a href='%s'>%s</a><br>", streamPath, streamPath)
})
if s != "" {
s = "<b>Live Streams</b><br>" + s
}
for name, p := range Plugins {
if pullcfg, ok := p.Config.(config.PullConfig); ok {
if pullonsub := pullcfg.GetPullConfig().PullOnSub; pullonsub != nil {
s += fmt.Sprintf("<b>%s pull stream on subscribe</b><br>", name)
for streamPath, url := range pullonsub {
s += fmt.Sprintf("<a href='%s'>%s</a> <-- %s<br>", streamPath, streamPath, url)
}
}
}
}
w.Write([]byte(s))
return
}
ss := strings.Split(r.URL.Path, "/")