You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: handler.go
    path of file: ./repos/bililive-go/src/servers
    
    the code of the file until where you have to start completion: package servers

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"os"
	"path/filepath"
	"sort"
	"strings"

	"github.com/gorilla/mux"
	"github.com/tidwall/gjson"
	"gopkg.in/yaml.v2"

	"github.com/hr3lxphr6j/bililive-go/src/configs"
	"github.com/hr3lxphr6j/bililive-go/src/consts"
	"github.com/hr3lxphr6j/bililive-go/src/instance"
	"github.com/hr3lxphr6j/bililive-go/src/listeners"
	"github.com/hr3lxphr6j/bililive-go/src/live"
	"github.com/hr3lxphr6j/bililive-go/src/recorders"
)

// FIXME: remove this
func parseInfo(ctx context.Context, l live.Live) *live.Info {
	inst := instance.GetInstance(ctx)
	obj, _ := inst.Cache.Get
    
func applyLiveRoomsByConfig(ctx context.Context, newLiveRooms []configs.LiveRoom) error {
	inst := instance.GetInstance(ctx)
	currentConfig := inst.Config
	currentConfig.RefreshLiveRoomIndexCache()
	newUrlMap := make(map[string]*configs.LiveRoom)
	for _, newRoom := range newLiveRooms {
		newUrlMap[newRoom.Url] = &newRoom
		if room, err := currentConfig.GetLiveRoomByUrl(newRoom.Url); err != nil {
			// add live
			if _, err := addLiveImpl(ctx, newRoom.Url, newRoom.IsListening); err != nil {
				return err
			}
		} else {
			live, ok := inst.Lives[live.ID(room.LiveId)]
			if !ok {
				return errors.New(fmt.Sprintf("live id: %s can not find", room.LiveId))
			}
			if room.IsListening != newRoom.IsListening {
				if newRoom.IsListening {
					// start listening
					if err := startListening(ctx, live); err != nil {
						return err
					}
				} else {
					// stop listening
					if err := stopListening(ctx, live.GetLiveId()); err != nil {
						return err
					}
				}
				room.IsListening = newRoom.IsListening
			}
		}
	}
	loopRooms := currentConfig.LiveRooms
	for _, room := range loopRooms {
		if _, ok := newUrlMap[room.Url]; !ok {
			// remove live
			live, ok := inst.Lives[live.ID(room.LiveId)]
			if !ok {
				return errors.New(fmt.Sprintf("live id: %s can not find", room.LiveId))
			}
			removeLiveImpl(ctx, live)
		}
	}
	return nil
}