30 lines
688 B
Go
30 lines
688 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, c)
|
|
|
|
case http.MethodOptions:
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
default:
|
|
log.Println("Method not implemented", r.Method)
|
|
http.Error(w, "Method not implemented", http.StatusMethodNotAllowed)
|
|
}
|
|
})
|
|
}
|