Add support for configs

This commit is contained in:
Ben Sarmiento
2023-10-18 21:09:25 +02:00
parent f9b5b1efac
commit 4650213218
19 changed files with 359 additions and 48 deletions

View File

@@ -5,20 +5,23 @@ import (
"net/http"
"os"
"github.com/debridmediamanager.com/zurg/internal/config"
"github.com/debridmediamanager.com/zurg/internal/torrent"
)
// Router creates a WebDAV router
func Router(mux *http.ServeMux) {
t := torrent.NewTorrentManager(os.Getenv("RD_TOKEN"))
c, err := config.LoadZurgConfig("./config.yml")
if err != nil {
log.Panicf("Config failed to load: %v", err)
}
t := torrent.NewTorrentManager(os.Getenv("RD_TOKEN"), c)
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)
HandlePropfindRequest(w, r, t, c)
case http.MethodGet:
HandleGetRequest(w, r, t)