add routers themes

This commit is contained in:
张超
2025-04-09 16:56:05 +08:00
parent 577cd10161
commit 33cb413a12
14 changed files with 275 additions and 118 deletions

View File

@@ -1,6 +1,7 @@
package routers // Add the package declaration at the top
import (
"go_blog/controllers"
"net/http"
"github.com/gin-gonic/gin"
@@ -8,15 +9,15 @@ import (
func RegisterRoutes(r *gin.Engine) {
// Frontend routes (dynamic themes)
r.GET("/", handlers.Home)
r.GET("/post/:id", handlers.ShowPost)
r.GET("/", controllers.Home)
r.GET("/post/:id", controllers.ShowPost)
// Admin panel
admin := r.Group("/admin", middleware.AuthRequired())
{
admin.GET("/themes", handlers.ListThemes)
admin.POST("/themes/switch", handlers.SwitchTheme)
}
// // Admin panel
// admin := r.Group("/admin", middleware.AuthRequired())
// {
// admin.GET("/themes", controllers.ListThemes)
// admin.POST("/themes/switch", controllers.SwitchTheme)
// }
// Static files for themes
r.StaticFS("/themes", http.Dir("web/themes"))