Remove unnecessary passing of cache by ref

This commit is contained in:
Ben Sarmiento
2023-11-29 00:48:08 +01:00
parent 7badbc50dc
commit 81aba99168
5 changed files with 11 additions and 15 deletions

View File

@@ -10,20 +10,19 @@ import (
intHttp "github.com/debridmediamanager.com/zurg/internal/http"
"github.com/debridmediamanager.com/zurg/internal/torrent"
"github.com/debridmediamanager.com/zurg/internal/universal"
"github.com/dgraph-io/ristretto"
"go.uber.org/zap"
)
// Router creates a WebDAV router
func Router(mux *http.ServeMux, getfile *universal.GetFile, c config.ConfigInterface, t *torrent.TorrentManager, cache *ristretto.Cache, log *zap.SugaredLogger) {
func Router(mux *http.ServeMux, getfile *universal.GetFile, c config.ConfigInterface, t *torrent.TorrentManager, log *zap.SugaredLogger) {
mux.HandleFunc("/http/", func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
requestPath := path.Clean(r.URL.Path)
if countNonEmptySegments(strings.Split(requestPath, "/")) > 3 {
getfile.HandleGetRequest(w, r, t, c, cache, log)
getfile.HandleGetRequest(w, r, t, c, log)
} else {
intHttp.HandleDirectoryListing(w, r, t, cache, log)
intHttp.HandleDirectoryListing(w, r, t, log)
}
case http.MethodHead:
@@ -38,13 +37,13 @@ func Router(mux *http.ServeMux, getfile *universal.GetFile, c config.ConfigInter
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "PROPFIND":
dav.HandlePropfindRequest(w, r, t, cache, log)
dav.HandlePropfindRequest(w, r, t, log)
case http.MethodDelete:
dav.HandleDeleteRequest(w, r, t, log)
case http.MethodGet:
getfile.HandleGetRequest(w, r, t, c, cache, log)
getfile.HandleGetRequest(w, r, t, c, log)
case http.MethodOptions:
w.WriteHeader(http.StatusOK)