This commit is contained in:
cangui 2025-06-18 19:23:23 +02:00
parent 36cbc0f5df
commit 9407799fa6
2 changed files with 11 additions and 8 deletions

View File

@ -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))
}

View File

@ -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))