Use a proper client for fetch byte

This commit is contained in:
Ben Sarmiento
2023-11-24 21:35:22 +01:00
parent 1e8c50a350
commit 595040ad7e
6 changed files with 97 additions and 116 deletions

View File

@@ -7,7 +7,7 @@ import (
"github.com/debridmediamanager.com/zurg/internal/config"
"github.com/debridmediamanager.com/zurg/internal/dav"
zurghttp "github.com/debridmediamanager.com/zurg/internal/http"
intHttp "github.com/debridmediamanager.com/zurg/internal/http"
"github.com/debridmediamanager.com/zurg/internal/torrent"
"github.com/debridmediamanager.com/zurg/internal/universal"
"github.com/debridmediamanager.com/zurg/pkg/logutil"
@@ -15,7 +15,7 @@ import (
)
// Router creates a WebDAV router
func Router(mux *http.ServeMux, c config.ConfigInterface, t *torrent.TorrentManager, cache *expirable.LRU[string, string]) {
func Router(mux *http.ServeMux, getfile *universal.GetFile, c config.ConfigInterface, t *torrent.TorrentManager, cache *expirable.LRU[string, string]) {
log := logutil.NewLogger().Named("net")
mux.HandleFunc("/http/", func(w http.ResponseWriter, r *http.Request) {
@@ -23,9 +23,9 @@ func Router(mux *http.ServeMux, c config.ConfigInterface, t *torrent.TorrentMana
case http.MethodGet:
requestPath := path.Clean(r.URL.Path)
if countNonEmptySegments(strings.Split(requestPath, "/")) > 3 {
universal.HandleGetRequest(w, r, t, c, cache)
getfile.HandleGetRequest(w, r, t, c, cache)
} else {
zurghttp.HandleDirectoryListing(w, r, t)
intHttp.HandleDirectoryListing(w, r, t)
}
case http.MethodHead:
@@ -47,7 +47,7 @@ func Router(mux *http.ServeMux, c config.ConfigInterface, t *torrent.TorrentMana
dav.HandleDeleteRequest(w, r, t, davlog)
case http.MethodGet:
universal.HandleGetRequest(w, r, t, c, cache)
getfile.HandleGetRequest(w, r, t, c, cache)
case http.MethodOptions:
w.WriteHeader(http.StatusOK)