Hotfix
This commit is contained in:
@@ -10,26 +10,24 @@ 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/debridmediamanager.com/zurg/pkg/logutil"
|
||||
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Router creates a WebDAV router
|
||||
func Router(mux *http.ServeMux, getfile *universal.GetFile, c config.ConfigInterface, t *torrent.TorrentManager, cache *expirable.LRU[string, string]) {
|
||||
log := logutil.NewLogger().Named("net")
|
||||
|
||||
func Router(mux *http.ServeMux, getfile *universal.GetFile, c config.ConfigInterface, t *torrent.TorrentManager, cache *expirable.LRU[string, string], 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)
|
||||
getfile.HandleGetRequest(w, r, t, c, cache, log)
|
||||
} else {
|
||||
intHttp.HandleDirectoryListing(w, r, t)
|
||||
intHttp.HandleDirectoryListing(w, r, t, log)
|
||||
}
|
||||
|
||||
case http.MethodHead:
|
||||
universal.HandleHeadRequest(w, r, t, cache)
|
||||
universal.HandleHeadRequest(w, r, t, cache, log)
|
||||
|
||||
default:
|
||||
log.Errorf("Request %s %s not supported yet", r.Method, r.URL.Path)
|
||||
@@ -38,16 +36,15 @@ func Router(mux *http.ServeMux, getfile *universal.GetFile, c config.ConfigInter
|
||||
})
|
||||
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
davlog := logutil.NewLogger().Named("dav")
|
||||
switch r.Method {
|
||||
case "PROPFIND":
|
||||
dav.HandlePropfindRequest(w, r, t, davlog)
|
||||
dav.HandlePropfindRequest(w, r, t, log)
|
||||
|
||||
case http.MethodDelete:
|
||||
dav.HandleDeleteRequest(w, r, t, davlog)
|
||||
dav.HandleDeleteRequest(w, r, t, log)
|
||||
|
||||
case http.MethodGet:
|
||||
getfile.HandleGetRequest(w, r, t, c, cache)
|
||||
getfile.HandleGetRequest(w, r, t, c, cache, log)
|
||||
|
||||
case http.MethodOptions:
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user