package dav import ( "log" "net/http" "os" "path" "github.com/debridmediamanager.com/zurg/internal/torrent" ) // Router creates a WebDAV router func Router(mux *http.ServeMux) { t := torrent.NewTorrentManager(os.Getenv("RD_TOKEN")) mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { requestPath := path.Clean(r.URL.Path) log.Println(r.Method, requestPath) switch r.Method { case "PROPFIND": HandlePropfindRequest(w, r, t) case http.MethodGet: HandleGetRequest(w, r, t) case http.MethodOptions: w.WriteHeader(http.StatusOK) default: log.Println("Method not implemented") http.Error(w, "Method not implemented", http.StatusMethodNotAllowed) } }) }