This commit is contained in:
2024-08-01 02:44:06 +08:00
parent 1860e3666d
commit a8891902c6
11 changed files with 121 additions and 57 deletions

11
main.go
View File

@@ -50,10 +50,16 @@ func main() {
func registerRoutes(r *gin.Engine) {
var items []models.Content
models.DB.Select("*").Find(&items)
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.tmpl", nil)
c.HTML(http.StatusOK, "index.tmpl", gin.H{
"Items": items,
})
})
r.GET("/createcontent", func(c *gin.Context) {
c.HTML(http.StatusOK, "content.tmpl", nil)
})
user := getUserInfo()
r.GET("/page/:id", func(c *gin.Context) {
id := c.Param("id")
@@ -72,6 +78,7 @@ func registerRoutes(r *gin.Engine) {
r.GET("/ws", controllers.WebSocketHandler)
r.POST("/content", controllers.CreateContentHandler)
r.POST("/login", controllers.UsersLoginHandler)
}