diff --git a/internal/streams/api.go b/internal/streams/api.go index d64c4846..d6042974 100644 --- a/internal/streams/api.go +++ b/internal/streams/api.go @@ -48,12 +48,12 @@ func apiStreams(w http.ResponseWriter, r *http.Request) { name = src } - if New(name, src) == nil { + if New(name, query["src"]...) == nil { http.Error(w, "", http.StatusBadRequest) return } - if err := app.PatchConfig(name, src, "streams"); err != nil { + if err := app.PatchConfig(name, query["src"], "streams"); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) } diff --git a/internal/streams/stream.go b/internal/streams/stream.go index bb832694..e194e0ac 100644 --- a/internal/streams/stream.go +++ b/internal/streams/stream.go @@ -21,6 +21,12 @@ func NewStream(source any) *Stream { return &Stream{ producers: []*Producer{NewProducer(source)}, } + case []string: + s := new(Stream) + for _, str := range source { + s.producers = append(s.producers, NewProducer(str)) + } + return s case []any: s := new(Stream) for _, src := range source { diff --git a/internal/streams/streams.go b/internal/streams/streams.go index 1bab036e..ae50e6c9 100644 --- a/internal/streams/streams.go +++ b/internal/streams/streams.go @@ -56,12 +56,14 @@ func Validate(source string) error { return nil } -func New(name string, source string) *Stream { - if Validate(source) != nil { - return nil +func New(name string, sources ...string) *Stream { + for _, source := range sources { + if Validate(source) != nil { + return nil + } } - stream := NewStream(source) + stream := NewStream(sources) streamsMu.Lock() streams[name] = stream