bugfixes
This commit is contained in:
@@ -147,12 +147,16 @@ func main() {
|
||||
func apiStreams(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 3*time.Second)
|
||||
defer cancel()
|
||||
|
||||
c := &mtx.Client{BaseURL: mtxAPI, User: os.Getenv("MTX_API_USER"), Pass: os.Getenv("MTX_API_PASS")}
|
||||
pl, err := c.Paths(ctx)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadGateway)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusBadGateway)
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
allowed := map[string]bool{}
|
||||
if streamsCSV != "" {
|
||||
for _, s := range strings.Split(streamsCSV, ",") {
|
||||
@@ -174,7 +178,7 @@ func apiStreams(w http.ResponseWriter, r *http.Request) {
|
||||
out.Items = append(out.Items, item{Name: p.Name, Live: p.Live(), Viewers: p.Viewers()})
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(out)
|
||||
_ = json.NewEncoder(w).Encode(out)
|
||||
}
|
||||
|
||||
func pageIndex(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user