Refactor routing

This commit is contained in:
Ben Sarmiento
2023-12-12 08:26:39 +01:00
parent 1661857194
commit 72d017682d
6 changed files with 62 additions and 62 deletions

View File

@@ -13,7 +13,7 @@ import (
"github.com/debridmediamanager/zurg/pkg/logutil"
)
func HandleListDirectories(torMgr *torrent.TorrentManager) ([]byte, error) {
func ServeRootDirectory(torMgr *torrent.TorrentManager) ([]byte, error) {
var buf bytes.Buffer
buf.WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:multistatus xmlns:d=\"DAV:\">")
buf.WriteString(dav.BaseDirectory("", ""))
@@ -29,7 +29,7 @@ func HandleListDirectories(torMgr *torrent.TorrentManager) ([]byte, error) {
return buf.Bytes(), nil
}
func HandleListTorrents(directory string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
func ServeTorrentsList(directory string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
torrents, ok := torMgr.DirectoryMap.Get(directory)
if !ok {
return nil, fmt.Errorf("cannot find directory %s", directory)
@@ -51,7 +51,7 @@ func HandleListTorrents(directory string, torMgr *torrent.TorrentManager, log *l
return buf.Bytes(), nil
}
func HandleListFiles(directory, torrentName string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
torrents, ok := torMgr.DirectoryMap.Get(directory)
if !ok {
return nil, fmt.Errorf("cannot find directory %s", directory)
@@ -86,7 +86,7 @@ func HandleListFiles(directory, torrentName string, torMgr *torrent.TorrentManag
return buf.Bytes(), nil
}
func HandlePropfindFile(directory, torrentName, fileName string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
func HandleSingleFile(directory, torrentName, fileName string, torMgr *torrent.TorrentManager, log *logutil.Logger) ([]byte, error) {
torrents, ok := torMgr.DirectoryMap.Get(directory)
if !ok {
return nil, fmt.Errorf("cannot find directory %s", directory)