UP
This commit is contained in:
parent
31849cf4d3
commit
7b01b1b928
34
main.go
34
main.go
@ -233,24 +233,28 @@ func startSFTPServer(base string) {
|
||||
// ---------- HTTP (Gin) ----------
|
||||
|
||||
func startHTTP() {
|
||||
bd := db.InitDB()
|
||||
app := gin.Default()
|
||||
bd := db.InitDB()
|
||||
app := gin.Default()
|
||||
|
||||
api := app.Group("/api/v1")
|
||||
routes.AddRoutes(api, bd)
|
||||
utils.CreateDefaultFolder(bd)
|
||||
api := app.Group("/api/v1")
|
||||
routes.AddRoutes(api, bd)
|
||||
utils.CreateDefaultFolder(bd)
|
||||
|
||||
app.Static("/static", "./web")
|
||||
app.NoRoute(func(c *gin.Context) {
|
||||
if strings.HasPrefix(c.Request.URL.Path, "/api/") {
|
||||
c.JSON(404, gin.H{"error": "Not found"})
|
||||
return
|
||||
}
|
||||
c.File("./web/index.html")
|
||||
})
|
||||
// Sert tout le dossier /app/web à la racine
|
||||
app.StaticFS("/", gin.Dir("./web", true))
|
||||
|
||||
log.Println("[HTTP] Serveur Gin sur http://0.0.0.0:8080")
|
||||
_ = app.Run(":8080")
|
||||
// (Optionnel) fallback SPA si tu as un router côté front
|
||||
app.NoRoute(func(c *gin.Context) {
|
||||
// Laisse passer les 404 d'API
|
||||
if strings.HasPrefix(c.Request.URL.Path, "/api/") {
|
||||
c.JSON(404, gin.H{"error": "Not found"})
|
||||
return
|
||||
}
|
||||
c.File("./web/index.html")
|
||||
})
|
||||
|
||||
log.Println("[HTTP] Serveur Gin sur http://0.0.0.0:8080")
|
||||
_ = app.Run(":8080")
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user