Files
zurg/internal/dav/router.go
Ben Sarmiento 464f522fea Proper logging
2023-10-20 01:38:05 +02:00

30 lines
685 B
Go

package dav
import (
"log"
"net/http"
"github.com/debridmediamanager.com/zurg/internal/config"
"github.com/debridmediamanager.com/zurg/internal/torrent"
)
// Router creates a WebDAV router
func Router(mux *http.ServeMux, c config.ConfigInterface, t *torrent.TorrentManager) {
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "PROPFIND":
HandlePropfindRequest(w, r, t, c)
case http.MethodGet:
HandleGetRequest(w, r, t)
case http.MethodOptions:
w.WriteHeader(http.StatusOK)
default:
log.Println("Method not implemented", r.Method)
http.Error(w, "Method not implemented", http.StatusMethodNotAllowed)
}
})
}