This commit is contained in:
2026-06-21 20:01:20 +08:00
parent 62732ba348
commit 42516257e0
9 changed files with 179 additions and 18 deletions
+3 -2
View File
@@ -46,16 +46,17 @@ func main() {
router.Use(middleware.SetUserContext(db))
// 8. Register routes.
router.GET("/", handlers.HomePage())
router.GET("/", handlers.HomePage(db))
router.GET("/login", handlers.LoginPage())
router.POST("/login", handlers.Login(db))
router.POST("/logout", handlers.Logout())
router.GET("/article/:slug", handlers.ArticleDetail(db))
// Protected admin routes.
admin := router.Group("/admin")
admin.Use(middleware.AuthRequired())
{
admin.GET("", handlers.AdminDashboard())
admin.GET("", handlers.AdminDashboard(db))
admin.GET("/articles/new", handlers.ArticleCreatePage(db))
admin.POST("/articles/new", handlers.ArticleCreate(db))
}