From 9407799fa6ec74b4b5acb6b8406ca37146f43739 Mon Sep 17 00:00:00 2001 From: cangui Date: Wed, 18 Jun 2025 19:23:23 +0200 Subject: [PATCH] up --- internal/route/main.go | 10 +++++++++- main.go | 9 ++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/internal/route/main.go b/internal/route/main.go index 96e5cdf..19f559c 100644 --- a/internal/route/main.go +++ b/internal/route/main.go @@ -9,10 +9,12 @@ import ( "fmt" "log" "net/http" - "time" "os" "path/filepath" + "time" + "github.com/gorilla/mux" + "golang.org/x/net/webdav" "gorm.io/gorm" ) @@ -63,6 +65,12 @@ func RoutesPublic(r *mux.Router, bd *gorm.DB) { http.Error(w, "Erreur lors de la génération de la playlist", http.StatusInternalServerError) } }) + webdavHandler := &webdav.Handler{ + Prefix: "/webdav/", + FileSystem: webdav.Dir("/app/upload"), + LockSystem: webdav.NewMemLS(), + } + r.PathPrefix("/webdav/").Handler(http.StripPrefix("/webdav/", webdavHandler)) } diff --git a/main.go b/main.go index af5212f..8f73458 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,6 @@ import ( "net/http" "github.com/gorilla/mux" - "golang.org/x/net/webdav" ) func main() { @@ -37,13 +36,9 @@ func main() { // 6.5. Exposer le dossier upload fs := http.StripPrefix("/upload/", http.FileServer(http.Dir("/app/upload"))) r.PathPrefix("/upload/").Handler(fs) + + - webdavHandler := &webdav.Handler{ - Prefix: "/webdav/", - FileSystem: webdav.Dir("/app/upload"), - LockSystem: webdav.NewMemLS(), - } - r.PathPrefix("/webdav/").Handler(http.StripPrefix("/webdav/", webdavHandler)) // 7. Lancer le serveur sur le port 4000 log.Fatal(http.ListenAndServe(":4000", r))