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) ----------
|
// ---------- HTTP (Gin) ----------
|
||||||
|
|
||||||
func startHTTP() {
|
func startHTTP() {
|
||||||
bd := db.InitDB()
|
bd := db.InitDB()
|
||||||
app := gin.Default()
|
app := gin.Default()
|
||||||
|
|
||||||
api := app.Group("/api/v1")
|
api := app.Group("/api/v1")
|
||||||
routes.AddRoutes(api, bd)
|
routes.AddRoutes(api, bd)
|
||||||
utils.CreateDefaultFolder(bd)
|
utils.CreateDefaultFolder(bd)
|
||||||
|
|
||||||
app.Static("/static", "./web")
|
// Sert tout le dossier /app/web à la racine
|
||||||
app.NoRoute(func(c *gin.Context) {
|
app.StaticFS("/", gin.Dir("./web", true))
|
||||||
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")
|
// (Optionnel) fallback SPA si tu as un router côté front
|
||||||
_ = app.Run(":8080")
|
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() {
|
func main() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user