up
This commit is contained in:
parent
36cbc0f5df
commit
9407799fa6
@ -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))
|
||||
|
||||
}
|
||||
|
||||
|
||||
9
main.go
9
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))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user