This commit is contained in:
cangui 2025-06-18 19:18:00 +02:00
parent d35b05b60b
commit 36cbc0f5df
3 changed files with 19 additions and 8 deletions

11
go.mod
View File

@ -14,9 +14,10 @@ require (
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/tools v0.28.0 // indirect
golang.org/x/mod v0.25.0 // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/tools v0.33.0 // indirect
gorm.io/datatypes v1.2.5 // indirect
gorm.io/hints v1.1.2 // indirect
)
@ -28,8 +29,8 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/joho/godotenv v1.5.1
golang.org/x/crypto v0.31.0
golang.org/x/text v0.21.0 // indirect
golang.org/x/crypto v0.39.0
golang.org/x/text v0.26.0 // indirect
gorm.io/driver/mysql v1.5.7 // indirect
gorm.io/driver/sqlite v1.5.7
gorm.io/gen v0.3.26

2
go.sum
View File

@ -73,6 +73,8 @@ golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

14
main.go
View File

@ -7,7 +7,9 @@ import (
"app/shelfly/internal/route"
"log"
"net/http"
"github.com/gorilla/mux"
"golang.org/x/net/webdav"
)
func main() {
@ -32,15 +34,22 @@ func main() {
// 6. Enregistrer les routes protégées sur ce sous-routeur
route.RoutesProtected(protected, bd)
//setupPortMappingWithFallback(4000, 4000)
// 6.5. Exposer le dossier upload
// 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))
}
// Fonction principale à appeler dans main()
// func setupPortMappingWithFallback(internalPort, externalPort uint16) {
// success := setupUPnPWithRenewal(internalPort, externalPort)
@ -100,7 +109,6 @@ func main() {
// return true
// }
// // NAT-PMP fallback
// func setupNATPMP(internalPort, externalPort uint16) {
// gatewayIP := getGatewayIP()