package server import ( "code.icod.de/dalu/htmxginpongo/model" "code.icod.de/dalu/htmxginpongo/storage" "github.com/flosch/pongo2/v6" "github.com/gin-gonic/gin" "github.com/godruoyi/go-snowflake" "time" ) func (s *Server) GETIndex(cx *gin.Context) { ctx := make(pongo2.Context) ctx["messages"] = storage.Messages cx.HTML(200, "index", ctx) } func (s *Server) POSTIndex(cx *gin.Context) { m := new(model.Message) m.Name = cx.PostForm("name") m.Text = cx.PostForm("text") m.Time = time.Now() m.ID = snowflake.ID() storage.AddMessage(m) ctx := make(pongo2.Context) ctx["message"] = m cx.HTML(200, "message/fragment", ctx) }