Files
zurg/internal/dav/router.go
Ben Sarmiento acee02377e Proper caching
2023-10-18 12:36:34 +02:00

36 lines
728 B
Go

package dav
import (
"log"
"net/http"
"os"
"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)
// default return
case http.MethodOptions:
w.WriteHeader(http.StatusOK)
default:
log.Println("Method not implemented")
http.Error(w, "Method not implemented", http.StatusMethodNotAllowed)
}
})
}