func GetFolders(w http.ResponseWriter, r *http.Request) {
	ren := context.Get(r, CtxRender).(*render.Render)
	out := FoldersResponse{}
	if version, ok := mux.Vars(r)["version"]; ok {
		if !apiVersionSet.Has(version) {
			ren.JSON(w, 400, errRes(400, "unsupported API version: "+version))
			return
		}
	}
	if pID, ok := mux.Vars(r)["id"]; ok {
		id, err := strconv.Atoi(pID)
		if err != nil {
			ren.JSON(w, 400, errRes(400, "invalid integer folder ID"))
			return
		}
		folder := &data.Folder{ID: id}
		if err := folder.Load(); err != nil {
			if err == sql.ErrNoRows {
				ren.JSON(w, 404, errRes(404, "folder ID not found"))
				return
			}
			log.Println(err)
			ren.JSON(w, 500, serverErr)
			return
		}
		out.Folders = []data.Folder{*folder}
		subfolders, err := folder.Subfolders()
		if err != nil {
			log.Println(err)
			ren.JSON(w, 500, serverErr)
			return
		}
		out.Subfolders = subfolders
		songs, err := data.DB.SongsForFolder(folder.ID)
		if err != nil {
			log.Println(err)
			ren.JSON(w, 500, serverErr)
			return
		}
		out.Songs = songs
		ren.JSON(w, 200, out)
		return
	}
	if pLimit := r.URL.Query().Get("limit"); pLimit != "" {
		var offset int
		var count int
		if n, err := fmt.Sscanf(pLimit, "%d,%d", &offset, &count); n < 2 || err != nil {
			ren.JSON(w, 400, errRes(400, "invalid comma-separated integer pair for limit"))
			return
		}
		folders, err := data.DB.LimitFolders(offset, count)
		if err != nil {
			log.Println(err)
			ren.JSON(w, 500, serverErr)
			return
		}
		out.Folders = folders
		ren.JSON(w, 200, out)
		return
	}
	folders, err := data.DB.AllFolders()
	if err != nil {
		log.Println(err)
		ren.JSON(w, 500, serverErr)
		return
	}
	out.Folders = folders
	ren.JSON(w, 200, out)
	return
}
GetFolders retrieves one or more folders from wavepipe, and returns a HTTP status and JSON.
It can be used to fetch a single folder, a limited subset of folders, or all folders, depending
on the request parameters.
package api
import (
	"database/sql"
	"fmt"
	"log"
	"net/http"
	"strconv"
	"github.com/mdlayher/wavepipe/data"
	"github.com/gorilla/context"
	"github.com/gorilla/mux"
	"github.com/unrolled/render"
)
type FoldersResponse struct {
	Error      *Error        `json:"error"`
	Folders    []data.Folder `json:"folders"`
	Subfolders []data.Folder `json:"subfolders"`
	Songs      []data.Song   `json:"songs"`
}