function restpath!(target, req) # @show req[:path] length(req[:path]) < 2 && return false return req[:path][1] == "rest" && startswith(req[:path][2], target) end restp(p, app...) = branch(req -> restpath!(p, req), app...) dispatch = stack( # Browsing restp("getMusicFolders", _ -> getMusicFolders()), restp("getMusicDirectory", req -> getMusicDirectory(req)), restp("getAlbumList", req -> getAlbumList(req)), restp("getGenres", _ -> getGenres()), restp("getArtists", _ -> getArtists()), restp("getArtist", r -> getArtist(r)), restp("getAlbum", req -> getAlbum(req)), restp("getSong", req -> getSong(req)), # Album/song list restp("getRandomSongs", req -> getRandomSongs(req)), # Searching restp("search3", req -> search3(req)), # Playlists restp("createPlaylist", req -> createPlaylist(req)), restp("getPlaylists", req -> getPlaylists(req)), restp("getPlaylist", req -> getPlaylist(req)), restp("updatePlaylist", req -> updatePlaylist(req)), restp("deletePlaylist", req -> deletePlaylist(req)), # User management restp("getUser", req -> getUser(req)), # Media retrieval restp("stream", req -> stream(req)), restp("getCoverArt", req -> getCoverArt(req)), # Media library scanning (can be used to check download status!) # getScanStatus startScan )