Rename and only return 404 when not found
This commit is contained in:
@@ -65,46 +65,53 @@ func AttachHandlers(router *chi.Mux, downloader *universal.Downloader, torMgr *t
|
|||||||
router.Post("/torrents/repair", hs.handleTriggerRepairAll)
|
router.Post("/torrents/repair", hs.handleTriggerRepairAll)
|
||||||
router.Post("/torrents/reset-repair-state", hs.handleResetRepairState)
|
router.Post("/torrents/reset-repair-state", hs.handleResetRepairState)
|
||||||
// version
|
// version
|
||||||
router.Get(fmt.Sprintf("/{mountType}/%s", version.FILE), hs.handleVersionFile)
|
router.Get("/{mountType}/version.txt", hs.handleVersionFile)
|
||||||
router.Head(fmt.Sprintf("/{mountType}/%s", version.FILE), hs.handleCheckVersionFile)
|
router.Head("/{mountType}/version.txt", hs.handleCheckVersionFile)
|
||||||
// download
|
// download
|
||||||
router.Get(fmt.Sprintf("/{mountType}/%s/{filename}", config.DOWNLOADS), hs.handleDownloadLink)
|
router.Get("/{mountType}/__downloads__/{filename}", hs.handleDownloadLink)
|
||||||
router.Head(fmt.Sprintf("/{mountType}/%s/{filename}", config.DOWNLOADS), hs.handleCheckDownloadLink)
|
router.Head("/{mountType}/__downloads__/{filename}", hs.handleCheckDownloadLink)
|
||||||
// file
|
// file
|
||||||
router.Get("/{mountType}/{directory}/{torrent}/{filename}", hs.handleDownloadFile)
|
router.Get("/{mountType}/{directory}/{torrent}/{filename}", hs.handleDownloadFile)
|
||||||
router.Head("/{mountType}/{directory}/{torrent}/{filename}", hs.handleCheckFile)
|
router.Head("/{mountType}/{directory}/{torrent}/{filename}", hs.handleCheckFile)
|
||||||
|
|
||||||
router.Get("/http/", hs.handleHttpRoot)
|
// http
|
||||||
router.Get(fmt.Sprintf("/http/%s/", config.DOWNLOADS), hs.handleHttpDownloadsList)
|
router.Get("/http/", hs.handleHttpRootDirectory)
|
||||||
router.Get("/http/{directory}/", hs.handleHttpTorrentsList)
|
router.Get("/http/__downloads__/", hs.handleHttpDownloads)
|
||||||
router.Get("/http/{directory}/{torrent}/", hs.handleHttpFilesList)
|
router.Get("/http/{directory}/", hs.handleHttpGroupDirectory)
|
||||||
|
router.Get("/http/{directory}/{torrent}/", hs.handleHttpTorrentFiles)
|
||||||
|
|
||||||
router.Get("/dav/", hs.handleDavRoot)
|
// dav
|
||||||
router.Get(fmt.Sprintf("/dav/%s/", config.DOWNLOADS), hs.handleDavDownloadsList)
|
router.Get("/dav/", hs.handleDavRootDirectory)
|
||||||
router.Get("/dav/{directory}/", hs.handleDavTorrentsList)
|
router.Get("/dav/__downloads__/", hs.handleDavDownloads)
|
||||||
router.Get("/dav/{directory}/{torrent}/", hs.handleDavFilesList)
|
router.Get("/dav/{directory}/", hs.handleDavGroupDirectory)
|
||||||
router.MethodFunc("PROPFIND", "/dav/", hs.handleDavRoot)
|
router.Get("/dav/{directory}/{torrent}/", hs.handleDavTorrentFiles)
|
||||||
router.MethodFunc("PROPFIND", fmt.Sprintf("/dav/%s/", config.DOWNLOADS), hs.handleDavDownloadsList)
|
|
||||||
router.MethodFunc("PROPFIND", "/dav/{directory}/", hs.handleDavTorrentsList)
|
|
||||||
router.MethodFunc("PROPFIND", "/dav/{directory}/{torrent}/", hs.handleDavFilesList)
|
|
||||||
|
|
||||||
router.Get("/infuse/", hs.handleInfuseRoot)
|
router.MethodFunc("PROPFIND", "/dav/", hs.handleDavRootDirectory)
|
||||||
router.Get(fmt.Sprintf("/infuse/%s/", config.DOWNLOADS), hs.handleInfuseDownloadsList)
|
router.MethodFunc("PROPFIND", "/dav/__downloads__/", hs.handleDavDownloads)
|
||||||
router.Get("/infuse/{directory}/", hs.handleInfuseTorrentsList)
|
router.MethodFunc("PROPFIND", "/dav/{directory}/", hs.handleDavGroupDirectory)
|
||||||
router.Get("/infuse/{directory}/{torrent}/", hs.handleInfuseFilesList)
|
router.MethodFunc("PROPFIND", "/dav/{directory}/{torrent}/", hs.handleDavTorrentFiles)
|
||||||
router.MethodFunc("PROPFIND", "/infuse/", hs.handleInfuseRoot)
|
|
||||||
router.MethodFunc("PROPFIND", fmt.Sprintf("/infuse/%s/", config.DOWNLOADS), hs.handleInfuseDownloadsList)
|
|
||||||
router.MethodFunc("PROPFIND", "/infuse/{directory}/", hs.handleInfuseTorrentsList)
|
|
||||||
router.MethodFunc("PROPFIND", "/infuse/{directory}/{torrent}/", hs.handleInfuseFilesList)
|
|
||||||
|
|
||||||
router.Get("/vidhub/", hs.handleVidHubRoot)
|
// infuse
|
||||||
router.Get(fmt.Sprintf("/vidhub/%s/", config.DOWNLOADS), hs.handleVidHubDownloadsList)
|
router.Get("/infuse/", hs.handleInfuseRootDirectory)
|
||||||
router.Get("/vidhub/{directory}/", hs.handleVidHubTorrentsList)
|
router.Get("/infuse/__downloads__/", hs.handleInfuseDownloads)
|
||||||
router.Get("/vidhub/{directory}/{torrent}/", hs.handleVidHubFilesList)
|
router.Get("/infuse/{directory}/", hs.handleInfuseGroupDirectory)
|
||||||
router.MethodFunc("PROPFIND", "/vidhub/", hs.handleVidHubRoot)
|
router.Get("/infuse/{directory}/{torrent}/", hs.handleInfuseTorrentFiles)
|
||||||
router.MethodFunc("PROPFIND", fmt.Sprintf("/vidhub/%s", config.DOWNLOADS), hs.handleVidHubDownloadsList)
|
|
||||||
router.MethodFunc("PROPFIND", "/vidhub/{directory}", hs.handleVidHubTorrentsList)
|
router.MethodFunc("PROPFIND", "/infuse/", hs.handleInfuseRootDirectory)
|
||||||
router.MethodFunc("PROPFIND", "/vidhub/{directory}/{torrent}", hs.handleVidHubFilesList)
|
router.MethodFunc("PROPFIND", "/infuse/__downloads__/", hs.handleInfuseDownloads)
|
||||||
|
router.MethodFunc("PROPFIND", "/infuse/{directory}/", hs.handleInfuseGroupDirectory)
|
||||||
|
router.MethodFunc("PROPFIND", "/infuse/{directory}/{torrent}/", hs.handleInfuseTorrentFiles)
|
||||||
|
|
||||||
|
// vidhub
|
||||||
|
router.Get("/vidhub/", hs.handleVidHubRootDirectory)
|
||||||
|
router.Get("/vidhub/__downloads__/", hs.handleVidHubDownloads)
|
||||||
|
router.Get("/vidhub/{directory}/", hs.handleVidHubGroupDirectory)
|
||||||
|
router.Get("/vidhub/{directory}/{torrent}/", hs.handleVidHubTorrentFiles)
|
||||||
|
|
||||||
|
router.MethodFunc("PROPFIND", "/vidhub/", hs.handleVidHubRootDirectory)
|
||||||
|
router.MethodFunc("PROPFIND", "/vidhub/__downloads__", hs.handleVidHubDownloads)
|
||||||
|
router.MethodFunc("PROPFIND", "/vidhub/{directory}", hs.handleVidHubGroupDirectory)
|
||||||
|
router.MethodFunc("PROPFIND", "/vidhub/{directory}/{torrent}", hs.handleVidHubTorrentFiles)
|
||||||
|
|
||||||
// note: reused handlers for dav and infuse
|
// note: reused handlers for dav and infuse
|
||||||
router.MethodFunc("PROPFIND", "/{mountType}/{directory}/{torrent}/{filename}", hs.checkSingleFileHandler)
|
router.MethodFunc("PROPFIND", "/{mountType}/{directory}/{torrent}/{filename}", hs.checkSingleFileHandler)
|
||||||
@@ -121,21 +128,17 @@ func AttachHandlers(router *chi.Mux, downloader *universal.Downloader, torMgr *t
|
|||||||
router.Get("/logs/upload/", hs.uploadLogsHandler)
|
router.Get("/logs/upload/", hs.uploadLogsHandler)
|
||||||
|
|
||||||
router.MethodNotAllowed(func(resp http.ResponseWriter, req *http.Request) {
|
router.MethodNotAllowed(func(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.log.Debugf("Method not allowed: %s %s %v", req.Method, req.URL, req.Header)
|
hs.log.Debugf("Method not allowed: %s %s (error=%v)", req.Method, req.URL, req.Header)
|
||||||
http.Error(resp, "Method not allowed", http.StatusMethodNotAllowed)
|
http.Error(resp, "Method not allowed", http.StatusMethodNotAllowed)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle root request
|
// handle root request
|
||||||
|
|
||||||
func (hs *Handlers) innerRootHandler(resp http.ResponseWriter, req *http.Request, handleFunc func(*torrent.TorrentManager) ([]byte, error), contentType string) {
|
func (hs *Handlers) innerRootDirectoryHandler(resp http.ResponseWriter, req *http.Request, handleFunc func(*torrent.TorrentManager) ([]byte, error), contentType string) {
|
||||||
out, err := handleFunc(hs.torMgr)
|
out, err := handleFunc(hs.torMgr)
|
||||||
if err != nil && strings.Contains(contentType, "xml") {
|
if err != nil {
|
||||||
hs.log.Debugf("Not implemented: %s %s", req.Method, req.URL)
|
hs.log.Errorf("Not found: %s %s (error=%v)", req.Method, req.URL, err)
|
||||||
resp.WriteHeader(http.StatusNotImplemented)
|
|
||||||
resp.Write([]byte("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:error xmlns:d=\"DAV:\" xmlns:s=\"DAV\"><s:exception>NotImplemented</s:exception><s:message>Not Implemented Method</s:message></d:error>"))
|
|
||||||
return
|
|
||||||
} else if err != nil {
|
|
||||||
http.NotFound(resp, req)
|
http.NotFound(resp, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -148,36 +151,32 @@ func (hs *Handlers) innerRootHandler(resp http.ResponseWriter, req *http.Request
|
|||||||
resp.Write(out)
|
resp.Write(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleHttpRoot(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleHttpRootDirectory(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerRootHandler(resp, req, intHttp.ServeRootDirectory, "text/html; charset=\"utf-8\"")
|
hs.innerRootDirectoryHandler(resp, req, intHttp.ServeRootDirectory, "text/html; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleDavRoot(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleDavRootDirectory(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerRootHandler(resp, req, dav.ServeRootDirectoryForDav, "text/xml; charset=\"utf-8\"")
|
hs.innerRootDirectoryHandler(resp, req, dav.ServeRootDirectoryForDav, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleInfuseRoot(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleInfuseRootDirectory(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerRootHandler(resp, req, dav.ServeRootDirectoryForInfuse, "text/xml; charset=\"utf-8\"")
|
hs.innerRootDirectoryHandler(resp, req, dav.ServeRootDirectoryForInfuse, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleVidHubRoot(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleVidHubRootDirectory(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerRootHandler(resp, req, dav.ServeRootDirectoryForVidHub, "text/xml; charset=\"utf-8\"")
|
hs.innerRootDirectoryHandler(resp, req, dav.ServeRootDirectoryForVidHub, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle torrent list request
|
// handle torrent list request
|
||||||
|
|
||||||
func (hs *Handlers) innerTorrentsListHandler(resp http.ResponseWriter, req *http.Request, handleFunc func(string, *torrent.TorrentManager) ([]byte, error), contentType string) {
|
func (hs *Handlers) innerGroupDirectoryHandler(resp http.ResponseWriter, req *http.Request, handleFunc func(string, *torrent.TorrentManager) ([]byte, error), contentType string) {
|
||||||
directory, err := url.PathUnescape(chi.URLParam(req, "directory"))
|
directory, err := url.PathUnescape(chi.URLParam(req, "directory"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
directory = chi.URLParam(req, "directory")
|
directory = chi.URLParam(req, "directory")
|
||||||
}
|
}
|
||||||
out, err := handleFunc(directory, hs.torMgr)
|
out, err := handleFunc(directory, hs.torMgr)
|
||||||
if err != nil && strings.Contains(contentType, "xml") {
|
if err != nil {
|
||||||
hs.log.Debugf("Not implemented: %s %s", req.Method, req.URL)
|
hs.log.Errorf("Not found: %s %s (error=%v)", req.Method, req.URL, err)
|
||||||
resp.WriteHeader(http.StatusNotImplemented)
|
|
||||||
resp.Write([]byte("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:error xmlns:d=\"DAV:\" xmlns:s=\"DAV\"><s:exception>NotImplemented</s:exception><s:message>Not Implemented Method</s:message></d:error>"))
|
|
||||||
return
|
|
||||||
} else if err != nil {
|
|
||||||
http.NotFound(resp, req)
|
http.NotFound(resp, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -190,25 +189,25 @@ func (hs *Handlers) innerTorrentsListHandler(resp http.ResponseWriter, req *http
|
|||||||
resp.Write(out)
|
resp.Write(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleHttpTorrentsList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleHttpGroupDirectory(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerTorrentsListHandler(resp, req, intHttp.ServeGroupDirectory, "text/html; charset=\"utf-8\"")
|
hs.innerGroupDirectoryHandler(resp, req, intHttp.ServeGroupDirectory, "text/html; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleDavTorrentsList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleDavGroupDirectory(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerTorrentsListHandler(resp, req, dav.ServeGroupDirectoryForDav, "text/xml; charset=\"utf-8\"")
|
hs.innerGroupDirectoryHandler(resp, req, dav.ServeGroupDirectoryForDav, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleInfuseTorrentsList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleInfuseGroupDirectory(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerTorrentsListHandler(resp, req, dav.ServeGroupDirectoryForInfuse, "text/xml; charset=\"utf-8\"")
|
hs.innerGroupDirectoryHandler(resp, req, dav.ServeGroupDirectoryForInfuse, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleVidHubTorrentsList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleVidHubGroupDirectory(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerTorrentsListHandler(resp, req, dav.ServeGroupDirectoryForVidHub, "text/xml; charset=\"utf-8\"")
|
hs.innerGroupDirectoryHandler(resp, req, dav.ServeGroupDirectoryForVidHub, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle files list request
|
// handle files list request
|
||||||
|
|
||||||
func (hs *Handlers) innerFilesListHandler(resp http.ResponseWriter, req *http.Request, handleFunc func(string, string, *torrent.TorrentManager, bool) ([]byte, error), contentType string) {
|
func (hs *Handlers) innerTorrentFilesHandler(resp http.ResponseWriter, req *http.Request, handleFunc func(string, string, *torrent.TorrentManager, bool) ([]byte, error), contentType string) {
|
||||||
directory, err := url.PathUnescape(chi.URLParam(req, "directory"))
|
directory, err := url.PathUnescape(chi.URLParam(req, "directory"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
directory = chi.URLParam(req, "directory")
|
directory = chi.URLParam(req, "directory")
|
||||||
@@ -218,12 +217,8 @@ func (hs *Handlers) innerFilesListHandler(resp http.ResponseWriter, req *http.Re
|
|||||||
torrentName = chi.URLParam(req, "torrent")
|
torrentName = chi.URLParam(req, "torrent")
|
||||||
}
|
}
|
||||||
out, err := handleFunc(directory, torrentName, hs.torMgr, hs.cfg.ShouldHideBrokenTorrents())
|
out, err := handleFunc(directory, torrentName, hs.torMgr, hs.cfg.ShouldHideBrokenTorrents())
|
||||||
if err != nil && strings.Contains(contentType, "xml") {
|
if err != nil {
|
||||||
hs.log.Debugf("Not implemented: %s %s", req.Method, req.URL)
|
hs.log.Errorf("Not found: %s %s (error=%v)", req.Method, req.URL, err)
|
||||||
resp.WriteHeader(http.StatusNotImplemented)
|
|
||||||
resp.Write([]byte("<?xml version=\"1.0\" encoding=\"utf-8\"?><d:error xmlns:d=\"DAV:\" xmlns:s=\"DAV\"><s:exception>NotImplemented</s:exception><s:message>Not Implemented Method</s:message></d:error>"))
|
|
||||||
return
|
|
||||||
} else if err != nil {
|
|
||||||
http.NotFound(resp, req)
|
http.NotFound(resp, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -236,38 +231,38 @@ func (hs *Handlers) innerFilesListHandler(resp http.ResponseWriter, req *http.Re
|
|||||||
resp.Write(out)
|
resp.Write(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleHttpFilesList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleHttpTorrentFiles(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerFilesListHandler(resp, req, intHttp.ServeFilesList, "text/html; charset=\"utf-8\"")
|
hs.innerTorrentFilesHandler(resp, req, intHttp.ServeTorrentFiles, "text/html; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleDavFilesList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleDavTorrentFiles(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerFilesListHandler(resp, req, dav.ServeTorrentFilesForDav, "text/xml; charset=\"utf-8\"")
|
hs.innerTorrentFilesHandler(resp, req, dav.ServeTorrentFilesForDav, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleInfuseFilesList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleInfuseTorrentFiles(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerFilesListHandler(resp, req, dav.ServeTorrentFilesForInfuse, "text/xml; charset=\"utf-8\"")
|
hs.innerTorrentFilesHandler(resp, req, dav.ServeTorrentFilesForInfuse, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleVidHubFilesList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleVidHubTorrentFiles(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerFilesListHandler(resp, req, dav.ServeTorrentFilesForVidHub, "text/xml; charset=\"utf-8\"")
|
hs.innerTorrentFilesHandler(resp, req, dav.ServeTorrentFilesForVidHub, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle downloads list request
|
// handle downloads list request
|
||||||
|
|
||||||
func (hs *Handlers) handleHttpDownloadsList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleHttpDownloads(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerTorrentsListHandler(resp, req, intHttp.ServeDownloadsList, "text/html; charset=\"utf-8\"")
|
hs.innerGroupDirectoryHandler(resp, req, intHttp.ServeDownloads, "text/html; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleDavDownloadsList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleDavDownloads(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerTorrentsListHandler(resp, req, dav.ServeDownloadsForDav, "text/xml; charset=\"utf-8\"")
|
hs.innerGroupDirectoryHandler(resp, req, dav.ServeDownloadsForDav, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleInfuseDownloadsList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleInfuseDownloads(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerTorrentsListHandler(resp, req, dav.ServeDownloadsForInfuse, "text/xml; charset=\"utf-8\"")
|
hs.innerGroupDirectoryHandler(resp, req, dav.ServeDownloadsForInfuse, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleVidHubDownloadsList(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleVidHubDownloads(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.innerTorrentsListHandler(resp, req, dav.ServeDownloadsForVidHub, "text/xml; charset=\"utf-8\"")
|
hs.innerGroupDirectoryHandler(resp, req, dav.ServeDownloadsForVidHub, "text/xml; charset=\"utf-8\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle delete request
|
// handle delete request
|
||||||
@@ -469,6 +464,8 @@ func (hs *Handlers) uploadLogsHandler(resp http.ResponseWriter, req *http.Reques
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Handlers) handleNotFound(resp http.ResponseWriter, req *http.Request) {
|
func (hs *Handlers) handleNotFound(resp http.ResponseWriter, req *http.Request) {
|
||||||
hs.log.Debugf("Not found: %s %s", req.Method, req.URL)
|
if hs.cfg.ShouldLogRequests() {
|
||||||
|
hs.log.Debugf("Not found: %s %s", req.Method, req.URL)
|
||||||
|
}
|
||||||
http.NotFound(resp, req)
|
http.NotFound(resp, req)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func ServeGroupDirectory(directory string, torMgr *torrent.TorrentManager) ([]by
|
|||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManager, shouldHideBrokenTorrents bool) ([]byte, error) {
|
func ServeTorrentFiles(directory, torrentName string, torMgr *torrent.TorrentManager, shouldHideBrokenTorrents bool) ([]byte, error) {
|
||||||
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
torrents, ok := torMgr.DirectoryMap.Get(directory)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("cannot find directory %s", directory)
|
return nil, fmt.Errorf("cannot find directory %s", directory)
|
||||||
@@ -94,7 +94,7 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage
|
|||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ServeDownloadsList(_ string, torMgr *torrent.TorrentManager) ([]byte, error) {
|
func ServeDownloads(_ string, torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
buf.WriteString("<ol>")
|
buf.WriteString("<ol>")
|
||||||
filenames := torMgr.DownloadMap.Keys()
|
filenames := torMgr.DownloadMap.Keys()
|
||||||
|
|||||||
Reference in New Issue
Block a user