Add option for http mount
This commit is contained in:
@@ -97,7 +97,7 @@ func handleSingleTorrent(requestPath string, w http.ResponseWriter, r *http.Requ
|
||||
return nil, fmt.Errorf("cannot find directory when generating single torrent: %s", requestPath)
|
||||
}
|
||||
|
||||
resp, err := createSingleTorrentResponse("/"+directory, sameNameTorrents, t)
|
||||
resp, err := createSingleTorrentResponse("/"+directory, sameNameTorrents)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot read directory (%s): %w", requestPath, err)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func createMultiTorrentResponse(basePath string, torrents []torrent.Torrent) (*d
|
||||
|
||||
// createTorrentResponse creates a WebDAV response for a single torrent
|
||||
// but it also handles the case where there are many torrents with the same name
|
||||
func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent, t *torrent.TorrentManager) (*dav.MultiStatus, error) {
|
||||
func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent) (*dav.MultiStatus, error) {
|
||||
var responses []dav.Response
|
||||
|
||||
// initial response is the directory itself
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package dav
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||
)
|
||||
|
||||
// Router creates a WebDAV router
|
||||
func Router(mux *http.ServeMux, c config.ConfigInterface, t *torrent.TorrentManager, cache *expirable.LRU[string, string]) {
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case "PROPFIND":
|
||||
HandlePropfindRequest(w, r, t, c, cache)
|
||||
|
||||
case http.MethodGet:
|
||||
HandleGetRequest(w, r, t, c, cache)
|
||||
|
||||
case http.MethodOptions:
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
default:
|
||||
log.Println("Method not implemented", r.Method)
|
||||
http.Error(w, "Method not implemented", http.StatusMethodNotAllowed)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user