This commit is contained in:
cangui 2025-05-09 19:34:14 +02:00
parent 2f4d8ee851
commit 4d99bf27e2

View File

@ -9,33 +9,38 @@ import (
"gorm.io/gorm"
)
// Routes non protégées
func RoutesPublic(r *mux.Router, db *gorm.DB) {
// Fichiers statiques (CSS, JS, etc.)
staticDir := "./frontend/assets/"
r.PathPrefix("/frontend/assets/").Handler(
http.StripPrefix("/frontend/assets/", http.FileServer(http.Dir(staticDir))),
)
// Page de login
r.HandleFunc("/login", renders.Login)
r.HandleFunc("/api/whatsapp/webhook", handlers.WebhookVerifyHandler()).Methods("GET")
r.HandleFunc("/api/whatsapp/webhook", handlers.WebhookReceiveHandler(db)).Methods("POST")
// Endpoint d'API pour se logger
r.HandleFunc("/api/login", handlers.LoginHandler(db)).Methods("POST")
}
// Routes protégées
func RoutesProtected(r *mux.Router, db *gorm.DB) {
}
// Routes protégées
func RoutesProtected(r *mux.Router, db *gorm.DB) {
r.HandleFunc("/jwt", renders.JwtTest)
r.HandleFunc("/api/message/send", handlers.SendWhatsAppMessage(db)).Methods("POST")
r.HandleFunc("/admin/user/{id}/conversations", renders.AdminConversationPage(db))
r.HandleFunc("/api/user/{id}/conversations", renders.AdminConversationRows(db))
r.HandleFunc("/admin/user/{id}/edit", renders.AdminUserEdit(db)).Methods("GET")
r.HandleFunc("/admin/user/new", renders.AdminUserCreate(db)).Methods("GET")
r.HandleFunc("/admin/user", renders.AdminUserList(db))
r.HandleFunc("/api/user/delete/{id}", handlers.AdminUserDelete(db)).Methods("DELETE")
r.HandleFunc("/api/user/update/{id}", renders.AdminUserUpdate(db)).Methods("PUT")
r.HandleFunc("/api/user/create", renders.CreateUserHandler(db)).Methods("POST")
r.HandleFunc("/admin/user/create-form", renders.AdminUserCreateForm()).Methods("GET")
r.HandleFunc("/dashboard", renders.Dashboard(db))
r.HandleFunc("/test/send", renders.TestMessagesPages)
@ -53,13 +58,13 @@ func RoutesProtected(r *mux.Router, db *gorm.DB) {
http.Redirect(w, r, "/login", http.StatusSeeOther)
})
// // Ici on place les vues et API qui doivent être protégées
// r.HandleFunc("/stream", StreamHandler)
// r.HandleFunc("/stream", StreamHandler)
// r.HandleFunc("/dashboard", renders.Dashboard(bd))
// r.HandleFunc("/settings", renders.Settings)
// r.HandleFunc("/library", renders.Library)
// r.HandleFunc("/settings", renders.Settings)
// r.HandleFunc("/library", renders.Library)
// r.HandleFunc("/menuLibary", renders.Library)
// r.HandleFunc("/godownloader/downloads", renders.GoDownload)
// r.HandleFunc("/godownloader/linkcollectors", renders.GoDownloadLinkCollectors)
@ -70,17 +75,17 @@ func RoutesProtected(r *mux.Router, db *gorm.DB) {
// r.HandleFunc("/api/user/delete/{id}", users.DeleteUser(bd)).Methods("DELETE")
// r.HandleFunc("/api/user/all/", users.ReadAllUser(bd)).Methods("GET")
// r.HandleFunc("/api/user/{id}", users.FindUserById(bd)).Methods("GET")
// // API download
// r.HandleFunc("/api/pathDownload/create", download.CreateSavePath(bd)).Methods("POST")
// r.HandleFunc("/api/pathDownload/update/{id}", download.UpdateSavePath(bd)).Methods("PUT")
// r.HandleFunc("/api/pathDownload/delete/{id}", download.DeleteSavePath(bd)).Methods("DELETE")
// r.HandleFunc("/api/pathDownload/all/", download.ReadAllSavePath(bd)).Methods("GET")
// //API Check path
// r.HandleFunc("/validate-path", download.PathValidationHandler)
//API Scan folder
}
}