Files
go_blog/controllers/showpost.go

21 lines
337 B
Go
Raw Normal View History

2025-04-09 16:56:05 +08:00
package controllers
import (
2025-04-15 16:47:00 +08:00
"go_blog/models"
2025-04-09 16:56:05 +08:00
"net/http"
2025-04-15 16:47:00 +08:00
"strconv"
2025-04-09 16:56:05 +08:00
"github.com/gin-gonic/gin"
)
func ShowPost(c *gin.Context) {
2025-04-15 16:47:00 +08:00
id, err := strconv.ParseInt(c.Param("id"), 10, 32)
if err != nil {
return
}
var content = models.Content{Cid: int32(id)}
models.DB.First(&content)
c.HTML(http.StatusOK, "post.tmpl", content)
2025-04-09 16:56:05 +08:00
}