add api endpoints and change config syntax

This commit is contained in:
seydx
2025-06-05 11:33:03 +03:00
parent 020549ef60
commit 493fa1ef6a
4 changed files with 85 additions and 20 deletions
+6 -5
View File
@@ -14,9 +14,9 @@ import (
func Init() {
var cfg struct {
Streams map[string]any `yaml:"streams"`
Publish map[string]any `yaml:"publish"`
Preload []string `yaml:"preload"`
Streams map[string]any `yaml:"streams"`
Publish map[string]any `yaml:"publish"`
Preload map[string]string `yaml:"preload"`
}
app.LoadConfig(&cfg)
@@ -29,6 +29,7 @@ func Init() {
api.HandleFunc("api/streams", apiStreams)
api.HandleFunc("api/streams.dot", apiStreamsDOT)
api.HandleFunc("api/preload", apiPreload)
if cfg.Publish == nil && cfg.Preload == nil {
return
@@ -44,8 +45,8 @@ func Init() {
}
if cfg.Preload != nil {
for _, src := range cfg.Preload {
Preload(src)
for name, rawQuery := range cfg.Preload {
Preload(name, rawQuery)
}
}
})